### Start Local Development Server Source: https://cs50.harvard.edu/x/psets/8/homepage This command starts a local HTTP server to preview the website. Users can then access the site by command-clicking or control-clicking the provided link in the terminal. ```bash http-server ``` -------------------------------- ### Get help with make Source: https://cs50.harvard.edu/x/psets/1/world This command invokes 'help50' with 'make hello' as an argument, providing assistance or debugging information specifically for the 'make hello' command. This is useful when encountering compilation errors. ```bash help50 make hello ``` -------------------------------- ### Create and open 'hello.c' file Source: https://cs50.harvard.edu/x/psets/1/world This command creates a new file named 'hello.c' and opens it in the 'code' editor (likely VS Code). This is the standard way to start writing source code for a C program. ```bash code hello.c ``` -------------------------------- ### Download Lecture Source Code with wget Source: https://cs50.harvard.edu/x/weeks/2 This command downloads a zip file containing lecture source code into your codespace. Ensure you have `wget` installed and are in the desired directory. ```bash wget https://cdn.cs50.net/2025/fall/lectures/2/src2.zip ``` -------------------------------- ### Run Flask Development Server Source: https://cs50.harvard.edu/x/psets/9/finance This command starts the Flask built-in web server for the C$50 Finance project. Accessing the outputted URL in a web browser will show the application in action. ```bash flask run ``` -------------------------------- ### Start SQLite and List Tables Source: https://cs50.harvard.edu/x/psets/7/fiftyville Commands to initiate the SQLite client for the fiftyville database and list all available tables. This is a crucial first step for exploring the database schema. ```bash sqlite3 fiftyville.db .tables ``` -------------------------------- ### Download Distribution Code using wget Source: https://cs50.harvard.edu/x/psets/3/runoff This command downloads the `runoff.zip` file from the specified URL using `wget`. Ensure `wget` is installed in your environment. This is the first step to obtain the necessary files for the problem set. ```bash wget https://cdn.cs50.net/2026/x/psets/3/runoff.zip ``` -------------------------------- ### Get User Input and Print Greeting in C Source: https://cs50.harvard.edu/x/notes/1 This C code snippet demonstrates how to prompt the user for their name using `get_string` and then print a personalized greeting using `printf` with the `%s` format specifier. It requires the `cs50.h` library for `get_string` and `stdio.h` for `printf`. ```c #include #include int main(void) { string answer = get_string("What's your name? "); printf("hello, %s\n", answer); } ``` -------------------------------- ### SQL Query Example: Get Escape City Source: https://cs50.harvard.edu/x/psets/7/fiftyville An example SQL query to determine the city the thief escaped to by querying flight and airport information. This involves correlating flight data with airport locations. ```sql -- Find the destination city of the flight taken on the day of the theft SELECT city FROM airports WHERE id = (SELECT destination_airport_id FROM flights WHERE id = (SELECT flight_id FROM passengers WHERE passport_number = (SELECT passport_number FROM people WHERE name = 'ERIK'))); ``` -------------------------------- ### Download and Unzip Project Files Source: https://cs50.harvard.edu/x/psets/8/homepage This snippet demonstrates how to download the project's starter files using `wget` and then extract them using `unzip`. It also includes commands to remove the downloaded ZIP file and navigate into the created project directory. ```bash wget https://cdn.cs50.net/2026/x/psets/8/homepage.zip unzip homepage.zip rm homepage.zip cd homepage ``` -------------------------------- ### SQL Query Example: Find Crime Scene Report Source: https://cs50.harvard.edu/x/psets/7/fiftyville An example SQL query to find a crime scene report matching a specific date and location. This is a starting point for identifying relevant records in the database. ```sql -- Find the crime scene report for the theft on July 28, 2025 on Humphrey Street SELECT * FROM crime_scene_reports WHERE year = 2025 AND month = 7 AND day = 28 AND street = 'Humphrey Street'; ``` -------------------------------- ### Download and Unzip Data using wget and unzip Source: https://cs50.harvard.edu/x/practice/seven-day-average This snippet demonstrates how to download a zip file containing project data using `wget` and then extract its contents using `unzip`. It's a common setup step for many command-line projects. ```bash wget https://cdn.cs50.net/2022/fall/labs/6/seven-day-average.zip unzip seven-day-average.zip rm seven-day-average.zip ``` -------------------------------- ### SQL Query Example: Get Thief's Name Source: https://cs50.harvard.edu/x/psets/7/fiftyville An example SQL query to retrieve the name of the thief based on information from the crime scene report and interviews. This demonstrates joining tables to gather information. ```sql -- Get the name of the person reported in the crime scene report SELECT name FROM people WHERE id IN (SELECT person_id FROM `order` WHERE id IN (SELECT order_id FROM passengers WHERE passport_number IN (SELECT passport_number FROM passengers WHERE flight_id IN (SELECT id FROM flights WHERE year = 2025 AND month = 7 AND day = 28 AND origin_airport_id = (SELECT id FROM airports WHERE city = 'Fiftyville'))))); ``` -------------------------------- ### SQL Query Example: Get Accomplice's Name Source: https://cs50.harvard.edu/x/psets/7/fiftyville An example SQL query to identify the thief's accomplice by looking for individuals associated with the thief's flight. This often involves checking for passengers on the same flight. ```sql -- Find the accomplice who assisted the thief on the flight SELECT name FROM people WHERE passport_number IN (SELECT passport_number FROM passengers WHERE flight_id = (SELECT id FROM flights WHERE year = 2025 AND month = 7 AND day = 28 AND origin_airport_id = (SELECT id FROM airports WHERE city = 'Fiftyville')) AND passport_number NOT IN (SELECT passport_number FROM passengers WHERE passport_number = (SELECT passport_number FROM people WHERE name = 'ERIK'))); ``` -------------------------------- ### Create a Context-Aware Chatbot with OpenAI API (Python) Source: https://cs50.harvard.edu/x/notes/0 This Python code snippet further refines a chatbot by incorporating a system prompt for context and instructions. It allows user input for the main prompt and uses the 'gpt-5' model, with the system prompt guiding the chatbot's behavior (e.g., limiting responses to one sentence and adopting a persona). The OpenAI library must be installed and configured. ```python from openai import OpenAI client = OpenAI() user_prompt = input("Prompt: ") system_prompt = "Limit your answer to one sentence. Pretend you're a cat." response = client.responses.create( input=user_prompt, instructions=system_prompt, model="gpt-5" ) print(response.output_text) ``` -------------------------------- ### Compile and Run C Program Source: https://cs50.harvard.edu/x/notes/1 Commands to create, compile, and execute a C program. 'code hello.c' creates the source file, 'make hello' compiles it into an executable, and './hello' runs the program. Ensure correct syntax in the C file for successful compilation. ```bash code hello.c make hello ./hello ``` -------------------------------- ### Install pyfiglet Module Source: https://cs50.harvard.edu/x/practice/figlet This command installs the pyfiglet library, which is necessary for generating ASCII art text. It is a prerequisite for running the FIGlet program. ```bash pip install pyfiglet ``` -------------------------------- ### Compile C program using make Source: https://cs50.harvard.edu/x/psets/1/world This command uses the 'make' utility to compile the 'hello.c' file. 'make' reads a Makefile (implicitly or explicitly) to determine how to build the target 'hello'. If successful, it produces an executable file named 'hello'. ```bash make hello ``` -------------------------------- ### FIGlet ASCII Art Example Source: https://cs50.harvard.edu/x/practice/figlet This is an example of ASCII art generated by the FIGlet program, showcasing its ability to create large letters from standard text. ```text _ _ _ _ _ _ | (_) | _____ | |_| |__ (_)___ | | | |/ / _ \ | __| '_ \| / __| | | | < __/ | |_| | | | \__ \ |_|_|_|\_\___| \__|_| |_|_|___/ ``` -------------------------------- ### Flask App: Handle GET and POST Requests Source: https://cs50.harvard.edu/x/practice/helloflask This Python code defines a Flask application with a single route ('/') that handles both GET and POST requests. For GET requests, it renders 'index.html'. For POST requests, it retrieves a 'color' value from the form data and renders 'color.html', passing the color value to the template. It also prints a debug message to the console upon receiving a POST request. ```python from flask import Flask, render_template, request app = Flask(__name__) @app.route("/", methods=["GET", "POST"]) def index(): if request.method == "GET": return render_template("index.html") else: print("Form submitted!") color = request.form.get("color") return render_template("color.html", color=color) ``` -------------------------------- ### Execute compiled program Source: https://cs50.harvard.edu/x/psets/1/world This command executes the compiled program named 'hello'. The './' prefix indicates that the executable is located in the current directory. ```bash ./hello ``` -------------------------------- ### Create 'world' directory Source: https://cs50.harvard.edu/x/psets/1/world This command creates a new directory named 'world' in the current file system location. It is a standard command-line utility used for organizing files and projects. ```bash mkdir world ``` -------------------------------- ### Example JSON Response from IEX API Source: https://cs50.harvard.edu/x/psets/9/finance This is an example of a JSON response that might be received from the IEX API when querying for stock data. It contains various details about a stock, such as its current price, volume, and company name. ```json { "avgTotalVolume":6787785, "calculationPrice":"tops", "change":1.46, "changePercent":0.00336, "close":null, "closeSource":"official", "closeTime":null, "companyName":"Netflix Inc.", "currency":"USD", "delayedPrice":null, "delayedPriceTime":null, "extendedChange":null, "extendedChangePercent":null, "extendedPrice":null, "extendedPriceTime":null, "high":null, "highSource":"IEX real time price", "highTime":1699626600947, "iexAskPrice":460.87, "iexAskSize":123, "iexBidPrice":435, "iexBidSize":100, "iexClose":436.61, "iexCloseTime":1699626704609, "iexLastUpdated":1699626704609, "iexMarketPercent":0.00864679844447232, "iexOpen":437.37, "iexOpenTime":1699626600859, "iexRealtimePrice":436.61, "iexRealtimeSize":5, "iexVolume":965, "lastTradeTime":1699626704609, "latestPrice":436.61, "latestSource":"IEX real time price", "latestTime":"9:31:44 AM", "latestUpdate":1699626704609, "latestVolume":null, "low":null, "lowSource":"IEX real time price", "lowTime":1699626634509, "marketCap":192892118443, "oddLotDelayedPrice":null, "oddLotDelayedPriceTime":null, "open":null, "openTime":null, "openSource":"official", "peRatio":43.57, "previousClose":435.15, "previousVolume":2735507, "primaryExchange":"NASDAQ", "symbol":"NFLX", "volume":null, "week52High":485, "week52Low":271.56, "ytdChange":0.4790450244167119, "isUSMarketOpen":true } ``` -------------------------------- ### Python Dictionary Access and Check Example Source: https://cs50.harvard.edu/x/practice/taqueria This example illustrates common ways to interact with Python dictionaries. It shows how to access a value using its key (`d[key]`) and how to check for the existence of a key before attempting to access it (`if key in d:`). These methods are fundamental for working with key-value data structures. ```python # Assuming 'd' is a dictionary and 'key' is a string # Accessing a value # value = d[key] # Checking if a key exists # if key in d: # # Key exists, proceed with accessing or other operations # pass ``` -------------------------------- ### Query Movie Database using SQL Source: https://cs50.harvard.edu/x/psets/7/movies Demonstrates how to query the `movies.db` database using `sqlite3` from the command line. This allows for testing SQL queries and redirecting output to a file. ```bash #!/bin/bash # Query the database and display results cat filename.sql | sqlite3 movies.db # Query the database and redirect output to a file cat filename.sql | sqlite3 movies.db > output.txt ``` -------------------------------- ### Select Names from People Table Source: https://cs50.harvard.edu/x/psets/7/movies This query selects the 'name' column from the 'people' table. It serves as a basic example of data retrieval and can be extended with WHERE clauses for more specific filtering. ```sql -- Select names SELECT name FROM people WHERE ... ``` -------------------------------- ### Illustrative Machine Code Source: https://cs50.harvard.edu/x/notes/2 This represents a simplified, illustrative example of machine code that a C program might be converted into by a compiler. Actual machine code is binary and significantly longer. ```plaintext 01010100 01001001 01001000 01010011 00100000 01001001 01010011 00100000 01000011 01010011 00110101 00110000 ``` -------------------------------- ### Implement Hello World in C Source: https://cs50.harvard.edu/x/psets/1/world This C code snippet implements a basic 'hello, world' program. It includes the standard input/output library and a main function that prints the string 'hello, world\n' to the console. This is a fundamental program for beginners learning C. ```c #include int main(void) { printf("hello, world\n"); } ``` -------------------------------- ### Compile C Code with Make and Help50 Source: https://cs50.harvard.edu/x/psets/1 Demonstrates how to compile C code using the `make` command and how to use `help50` to diagnose compilation errors. `make` is a build automation tool, and `help50` is a utility to provide more understandable error messages for CS50 assignments. ```bash make hello ``` ```bash help50 make hello ``` -------------------------------- ### Get Available Fonts with pyfiglet Source: https://cs50.harvard.edu/x/practice/figlet This Python code retrieves a list of all available fonts that can be used with the pyfiglet library. This is useful for exploring font options. ```python from pyfiglet import Figlet figlet = Figlet() available_fonts = figlet.getFonts() print(available_fonts) ``` -------------------------------- ### Submit Speller Work with submit50 Source: https://cs50.harvard.edu/x/psets/5/speller Submit your completed speller project using the 'submit50' tool. This command will guide you through the submission process and prompts. ```bash submit50 cs50/problems/2026/x/speller ``` -------------------------------- ### Greet User using get_string Source: https://cs50.harvard.edu/x/notes/2 This C code snippet demonstrates a simple program that prompts the user for their name using get_string and then prints a greeting. It requires the cs50.h and stdio.h libraries. The program takes user input and outputs a personalized greeting. ```c // Uses get_string #include #include int main(void) { string answer = get_string("What's your name? "); printf("hello, %s\n", answer); } ``` -------------------------------- ### List directory contents Source: https://cs50.harvard.edu/x/psets/1/world This command lists the contents of the current directory. It is used here to verify that both the source file 'hello.c' and the compiled executable 'hello' have been created. ```bash ls ``` -------------------------------- ### Test Inheritance Program Output Source: https://cs50.harvard.edu/x/psets/5/inheritance This example demonstrates the expected output when running the 'inheritance' program. It shows the blood types of a child, their parents, and grandparents, illustrating how alleles are passed down through generations. ```bash $ ./inheritance Child (Generation 0): blood type OO Parent (Generation 1): blood type AO Grandparent (Generation 2): blood type OA Grandparent (Generation 2): blood type BO Parent (Generation 1): blood type OB Grandparent (Generation 2): blood type AO Grandparent (Generation 2): blood type BO ``` -------------------------------- ### Check code correctness with check50 Source: https://cs50.harvard.edu/x/psets/1/world This command runs the 'check50' tool to automatically test the 'hello' program against CS50's predefined test cases for the 'world' problem in the 2026 curriculum. It provides feedback on whether the code meets the correctness requirements. ```bash check50 cs50/problems/2026/x/world ``` -------------------------------- ### C: Integer Division and Truncation Source: https://cs50.harvard.edu/x/notes/1 Illustrates integer division in C, where the result of dividing two integers is truncated (any decimal part is discarded). For example, 7 / 2 results in 3, not 3.5. ```c // Division with ints, demonstrating truncation #include #include int main(void) { // Prompt user for x int x = get_int("What's x? "); // Prompt user for y int y = get_int("What's y? "); // Divide x by y printf("%i\n", x / y); } ``` -------------------------------- ### Machine Code Representation during Assembling Source: https://cs50.harvard.edu/x/notes/2 This example shows a sequence of binary numbers representing machine code. This is the output of the assembler, which translates human-readable assembly instructions into the binary format that the CPU can execute. ```binary 01111111010001010100110001000110 00000010000000010000000100000000 00000000000000000000000000000000 00000000000000000000000000000000 00000001000000000011111000000000 00000001000000000000000000000000 00000000000000000000000000000000 ... ``` -------------------------------- ### Basic C 'Hello, World!' Program Source: https://cs50.harvard.edu/x/notes/1 A fundamental C program that prints 'hello, world\n' to the console. It includes the stdio.h header for input/output functions like printf. Proper syntax, including the semicolon and newline character '\n', is crucial. ```c // A program that says hello to the world #include int main(void) { printf("hello, world\n"); } ``` -------------------------------- ### Check code style with style50 Source: https://cs50.harvard.edu/x/psets/1/world This command uses the 'style50' tool to analyze the 'hello.c' file for code style compliance. It suggests improvements by highlighting additions (green) and deletions (red) to adhere to common C coding style guidelines. ```bash style50 hello.c ```