Python Foundations Free offline workbook · Kids Web Dev Start here. Extract the ZIP and follow the three setup lessons below. Choose the steps for Windows or Mac. Use the VS Code lesson if you want to use that editor. Install Python on Windows or Mac Follow the Windows or Mac steps for your computer. Python runs your code. The terminal is the window where you tell your computer which Python file to run. On Windows, use Command Prompt. If Python is already installed, start with the version command for your computer. Windows · install Python 1. Open the official Windows download page. Choose Python install manager, then open the downloaded installer and select Install. Download Python for Windows · https://www.python.org/downloads/windows/ 2. Open the Start menu, type Command Prompt, and open it. Type the line below and press Enter. If this is a fresh installation, accept the prompt to install Python and let it finish. If the manager says it needs a Python version, enter py install default, then run the version command again. py --version What you should see · A version such as Python 3.14.2. Use Python 3.10 or newer for Foundations. Windows · open the workbook and run the file 1. If you need the workbook, choose Download workbook (ZIP) on the course page. In File Explorer, right-click the ZIP and choose Extract All, then Extract. Open the extracted folder and make sure you can see workbook.txt. Use that folder for the steps below. 2. Click the address bar in File Explorer. Copy the full folder path with Ctrl+C. In Command Prompt, type cd /d followed by a space. Paste the path between double quotes and press Enter. Replace the sample path with the one you copied. cd /d "C:\Users\Sam\Downloads\python-foundations-workbook" 3. List the files in this folder. Look for workbook.txt and the setup folder. dir 4. Run the setup file from this folder. If python --version was the command that worked on your computer, use python instead of py. py setup\check_python.py What you should see · Python is ready! Mac · install Python 1. Open the official macOS download page and choose the macOS installer for a stable Python 3 release. Open the downloaded .pkg and follow the installer. Download Python for Mac · https://www.python.org/downloads/macos/ 2. Press Command–Space, type Terminal and press Return. Type the line below and press Return. python3 --version What you should see · A version such as Python 3.14.2. Use Python 3.10 or newer for Foundations. Mac · open the workbook and run the file 1. If you need the workbook, choose Download workbook (ZIP) on the course page. In Finder, double-click the ZIP to extract the workbook. Open the extracted folder and look for workbook.txt. 2. In Terminal, type cd followed by a space. Drag the extracted workbook folder from Finder into Terminal, then press Return. Terminal fills in the folder path for you. 3. List the files in this folder. Look for workbook.txt and the setup folder. ls 4. Run the setup file from this folder. python3 setup/check_python.py What you should see · Python is ready! If a command fails 1. If Windows says py is not recognised, open a fresh Command Prompt and try python --version. If it shows Python 3.10 or newer, use python instead of py. If both commands fail, reopen the Python installer and check that installation finished. 2. If Mac says python3 was not found or offers to install developer tools, finish the Python.org installer and open a fresh Terminal. Try python3 --version again. 3. If Python can’t open the file, list the folder again with dir on Windows or ls on Mac. For the setup check, you should see workbook.txt and setup. For a lesson, you should see instructions.txt and its .py files. Change to the right folder and try again. 4. If you see >>>, you opened Python’s interactive prompt. Type exit() and press Enter to return to the terminal. Then run the full command with the file name. Set up VS Code for Python VS Code is an editor for writing and saving code. Its built-in terminal lets you run that code using the Python you installed in the terminal setup lesson. Install VS Code and the Python extension 1. Have Python 3.10 or newer installed and a workbook ZIP extracted. If your setup check hasn’t printed Python is ready! yet, follow the terminal setup lesson first. 2. Windows. Choose the Windows User Installer, open it, and follow the installer. Then open Visual Studio Code from the Start menu. Mac. Choose the Mac download. If it arrives as a ZIP, double-click it in Finder, move Visual Studio Code to Applications, and open it. Download Visual Studio Code · https://code.visualstudio.com/download 3. Select Extensions in the left sidebar. Search for Python. Choose the extension published by Microsoft and select Install. Find the Microsoft Python extension · https://marketplace.visualstudio.com/items?itemName=ms-python.python Open your workbook and select Python 1. In VS Code, select File → Open Workspace from File. Pick the .code-workspace file in the folder that contains workbook.txt. It sets VS Code to run each Python file from its own folder. If asked whether you trust the folder, confirm you downloaded it from Kids Web Dev before accepting. You can also use File → Open Folder and run from the lesson folder in the terminal. 2. In the Explorer sidebar, open setup and select check_python.py. Open the Command Palette with Ctrl+Shift+P on Windows or Command–Shift–P on Mac. 3. Type Python: Select Interpreter and select that command. An interpreter is the program that runs your Python files. Select the Python 3 installation you checked in the terminal. 4. With check_python.py open, click the triangle in the upper right of the editor. If it opens a menu, select Run Python File in Terminal. Look for the result in the Terminal panel at the bottom. What you should see · Python is ready! 5. If you prefer typing the command, choose Terminal → New Terminal. Open it from the workbook folder and use the Windows or Mac command below. py setup\check_python.py python3 setup/check_python.py Open an online lesson in VS Code 1. From the online lesson, expand Practice in VS Code. Use the current workbook ZIP for that course. The lesson link points to files inside the extracted copy. 2. Windows. In File Explorer, right-click the extracted workbook folder and choose Copy as path. If the option isn’t there, open the folder and copy its path from the address bar. Mac. Select the extracted folder in Finder and press Option–Command–C. Choose the folder containing workbook.txt. 3. Paste the path under Workbook folder on this computer and choose Save workbook folder. Choose Open example in VS Code or Open starter in VS Code. If the browser asks to open Visual Studio Code, choose Open. 4. In VS Code, run the open file with the triangle. To work offline, just open the lesson files in the Explorer sidebar. Save edits with Ctrl+S on Windows or Command–S on Mac. Your edits are saved inside your local workbook folder. If VS Code can’t run the file 1. If Python: Select Interpreter or the triangle is missing, check that the active file ends in .py and that the Microsoft Python extension is installed and enabled. Reopen VS Code, then select the interpreter again. 2. If the interpreter list is empty, check Python in a separate terminal first. If the version command works there, close and reopen VS Code to pick up the installation. 3. If the online link opens an empty editor or doesn’t launch VS Code, check that the ZIP was extracted and the saved path points to the correct course folder. You can always open the files through File → Open Folder and run them there. Run a Python file on Windows or Mac Use the supplied script to see what happens when Python reads answers and prints a result. Then use the same steps to run any file in your workbook. Open the extracted workbook 1. Start from the setup check in the first lesson. If Python is installed, download and extract the workbook ZIP. Open the folder that contains workbook.txt. Inside setup you’ll find run_python.py and run_python-input.txt. 2. Open the terminal in the workbook folder. On Windows, copy the folder path from File Explorer. In Command Prompt type cd /d, a space, and the folder path in double quotes. On Mac, type cd and a space in Terminal, drag the folder from Finder into the window, and press Return. 3. Check where you are before running a file. On Windows, type dir and press Enter. On Mac, type ls and press Return. You should see workbook.txt and the setup and lessons folders. Windows · run a file and enter answers 1. In Command Prompt, run the file below. The first word starts Python and the rest tells it which file to open. py setup\run_python.py 2. When Python asks for a name, type Sam and press Enter. When it asks where you’re sending from, type Base Camp and press Enter. After the result, the Command Prompt is ready for another command. What you should see · Sam is sending from Base Camp. 3. Command Prompt can also read the supplied answers from a file. The < symbol sends the lines in that text file to the program. Use Command Prompt for this command. py setup\run_python.py < setup\run_python-input.txt What you should see · Sam is sending from Base Camp. Mac · run a file and enter answers 1. In Terminal, run the file below. The first word starts Python and the rest tells it which file to open. python3 setup/run_python.py 2. When Python asks for a name, type Sam and press Return. When it asks where you’re sending from, type Base Camp and press Return. After the result, the terminal is ready for another command. What you should see · Sam is sending from Base Camp. 3. Terminal can also read the supplied answers from a file. The < symbol sends the lines in that text file to the program. python3 setup/run_python.py < setup/run_python-input.txt What you should see · Sam is sending from Base Camp. Run the same file in VS Code or Coding Studio 1. In VS Code, open the workbook folder, then open setup/run_python.py from the Explorer sidebar. Click Run Python File. The Terminal panel at the bottom is where you type Sam and Base Camp, pressing Enter after each line. 2. In browser-based Coding Studio, programs that read input have a Program input box. Type your answers there on separate lines before choosing Run. The output appears below. The Check button supplies the input for its own cases. Repeat these steps for the course files 1. Open workbook.txt and find the folder listed under Lesson files. In File Explorer or Finder, open that folder. It contains instructions.txt, example.py when the lesson has an example, and starter.py. 2. Use the same cd steps to enter the lesson folder. Run the example first. Edit starter.py in your code editor, save it, and run it again. Use the Windows pair below in Command Prompt or the Mac pair in Terminal. py example.py py starter.py python3 example.py python3 starter.py 3. Some workbook programs wait for input without printing a question. The lesson lists the lines to enter. If you need to stop a program and get the terminal prompt back, press Ctrl+C. On Mac, use Control for this shortcut. Study on your own 1. Read Before you start. Try one of those skills briefly from memory. 2. Predict what the example will do, run it, and trace the line that explains the result. Change one value and try again. 3. Open the separate task. Compare the expected and actual output. If it fails, read the error or case feedback, then test one small change. 4. Try your own input, or change a value in a program that runs without input. Record what you expected and what happened. Save or download your code. 5. Use By the end as a checklist. Explain one line in your own words, or rebuild a short part tomorrow to see what you remember. Each session has a worked example and a separate starter. Use the matching .py files from the ZIP or copy the code below into its own file. When a local lab needs extra tools, see Install Python packages for a local project at the end of this workbook, or open setup/install-python-packages.txt in the ZIP. Open a terminal in the lesson folder. Run python3 example.py or python3 starter.py. On Windows, use py in place of python3. Use Python 3.10 or later for the main lessons and Python 3.11 or newer for the document lab. Type one input line at a time. In the ZIP, input files can also be passed directly. Try python3 starter.py < starter-input.txt on macOS or Linux, or py starter.py < starter-input.txt in Windows Command Prompt. A blank input line means press Enter without typing. Compare your terminal output with the expected output printed in the workbook. Keep a copy of your working programs. Work with fictional data. ────────────────────────────────────── 1. Broadcast from Base Camp · Send Your First Signal Run a Python file, predict the order of two lines, and change its message. Lesson files · lessons/first-programs/first-print Before you start Start here with no coding experience. By the end - Use print() and matching quotes to show text. - Predict the order of two lines, then run the program to check your prediction. Where you can use it Put a welcome message at the start of a game. Print the rules on the next line so the player reads them in order. Read the program from top to bottom. Each print() call sends one line to the console, where the program shows its output. The matching quotes around "Base camp online." mark the start and end of the text. Predict which line will appear first, then press Run. For local practice, save the code as main.py and run python3 main.py in a terminal. Predict What will appear on the first line? - Base camp online. - Send a reply. Worked example (example.py) print("Base camp online.") print("Send a reply.") Example result Base camp online. Send a reply. Change the first line of output to Signal received! and the second to Mission ready. Keep the punctuation so Check can match both lines. Starter program (starter.py) print("Base camp online.") print("Send a reply.") Hint Change the text inside each pair of quotes. Run before and after the edit so you can see which line changed. Case 1. Try the sample Input (No input.) Expected output Signal received! Mission ready. Stretch Make a three-line broadcast for a mission you invent and write down its expected output. Reflect Which characters tell Python that Base camp online. is text? Check your prediction Base camp online. Python runs these two instructions in the order you wrote them. ────────────────────────────────────── 2. Broadcast from Base Camp · Give a Robot a Profile Store text, a whole number and a yes-or-no value, then change a stored value. Lesson files · lessons/first-programs/variables-and-types Before you start - Show a message with print(). By the end - Use variables to store text, a whole number and True or False. - Trace what print() shows before and after a variable is reassigned. Where you can use it Keep a player’s name, score and ready status in variables. Update the score when the player earns a point. An assignment uses = to store a value under a name. The robot variable holds a string, which is Python's name for text. The battery variable holds an integer, or whole number. The online variable holds a Boolean, which is either True or False. When you write print(battery), Python looks up the value that battery holds at that moment. In the example that value is 80 on the first call and 65 after the next assignment. Predict Which value is printed after battery = 65? - 80 - 65 Worked example (example.py) robot = "Pip" battery = 80 online = True print(robot) print(battery) battery = 65 print(battery) print(online) Example result Pip 80 65 True Set robot to Nova, battery to 90 and online to False. Print the name, battery and online state in that order. Starter program (starter.py) robot = "Pip" battery = 80 online = True print(robot) print(battery) battery = 65 print(battery) print(online) Hint Use quotes for Nova. Write 90 and False without quotes so the values keep their Python types. Case 1. Try the sample Input (No input.) Expected output Nova 90 False Stretch Print the battery, use battery = battery - 15 to save the new level, then print it again. Reflect What would change if you wrote print("robot")? Check your prediction 65 The second assignment changes what battery refers to. It leaves the earlier output alone. ────────────────────────────────────── 3. Broadcast from Base Camp · Pack for the Expedition Calculate a total and label it using an f-string. Lesson files · lessons/first-programs/numbers-and-f-strings Before you start - Store whole numbers in variables. - Print the value stored under a name. By the end - Use multiplication to calculate a supply total. - Use an f-string to put that total in a label. - Test that the label updates when the group size changes. Where you can use it Work out how many pencils a class needs. Multiply the number of desks by the pencils per desk and show the total with a label. Python uses * for multiplication. Store the number of people and the packs for each person under two names. Then multiply them to get the total. An f-string starts with f before the opening quote. At the spot marked {total}, Python inserts the current value of total. Try changing people to 5 and predict the new label before running it. Predict If people becomes 0, what total should appear? - 0 - 2 Worked example (example.py) people = 4 packs_each = 2 total = people * packs_each print(f"Supply packs: {total}") Example result Supply packs: 8 Pack three supply packs per person for a group of six. Print Supply packs: 18 using the calculation. Starter program (starter.py) people = 4 packs_each = 2 total = people * packs_each print(f"Supply packs: {total}") Hint Change people and packs_each. Keep the expression for total so the label stays correct if you change the numbers again. Case 1. Try the sample Input (No input.) Expected output Supply packs: 18 Stretch Use + to add two spare packs to the total. Predict and explain the new output for six people and for zero people. Reflect Which numbers can you change without touching the print call? Check your prediction 0 Zero people times any number of packs per person gives zero. ────────────────────────────────────── 4. Broadcast from Base Camp · Build a Mission Card Build a reusable mission card that recalculates meals when the crew size changes. Lesson files · lessons/first-programs/mission-card Before you start - Multiply two named values to find a total. - Put a variable in a label with an f-string. By the end - Use the crew size from Program input in both a label and a calculation. - Test a larger crew and a crew of zero. Where you can use it Make a snack planner for a group. Enter the headcount each time and let the planner recalculate what to pack. Store the mission name, crew size and meals per person before calculating and printing the result. Use the same crew variable for both the label and the multiplication so the card stays in sync. Keep the starter's crew = int(input()) line. It reads one line from Program input and turns it into a whole number. The next module shows how to write that step yourself. Try a different crew size by changing the number in Program input and running again. Predict In the worked example, which line should you change to send more people? - The text printed by the f-string. - The assignment to crew. Worked example (example.py) mission = "Ice Survey" crew = 2 print(f"{mission} has {crew} crew.") Example result Ice Survey has 2 crew. Create a mission card for Moon Relay with two meals per crew member. Use the crew size from Program input. Print Mission: Moon Relay, then Crew: and Meals: with their numbers on separate lines. For a crew of 3, the card should show 6 meals. Starter program (starter.py) mission = "Moon Relay" crew = int(input()) meals_each = 2 print(f"Mission: {mission}") Starter input 3 Hint Get the first two output lines working. Then calculate meals = crew * meals_each and insert meals into the third line. Case 1. Try the sample Input 3 Expected output Mission: Moon Relay Crew: 3 Meals: 6 Case 2. Larger crew Input 5 Expected output Mission: Moon Relay Crew: 5 Meals: 10 Case 3. Empty crew Input 0 Expected output Mission: Moon Relay Crew: 0 Meals: 0 Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Make a card for a new mission. Decide how many meals each person needs, then choose a crew size and predict the result. Reflect Show a change to the crew size and explain why the meal count changed. Check your prediction The assignment to crew. Changing the source value keeps the label and future calculations in sync. ────────────────────────────────────── 5. The Club Pass Desk · Make a Message Personal Supply a line of input and tidy the text before using it. Lesson files · lessons/input-and-decisions/text-and-input Before you start - Store text under a name. - Put a name inside an f-string. By the end - Use input() to read a line while the program runs. - Use strip() to trim the ends of a line. - Explain why spaces between words stay in the greeting. Where you can use it Ask a player for their name when a game starts. Trim stray spaces before showing their name on a welcome screen. input() reads one line and returns text. In Studio, enter the line in Program input before you run. In a local terminal, type the line when the program waits and press Enter. Add .strip() to trim whitespace such as spaces and tabs from the two ends of the line. Spaces inside the name stay in place. Try a two-word name with extra spaces at the ends. Predict Where do the spaces around River go? - strip() trims them. - They stay in the greeting. Worked example (example.py) name = input().strip() print(f"Hello, {name}!") Example input River Example result Hello, River! Read the team name, trim it and print Team: followed by one space and the cleaned name. Starter program (starter.py) name = input().strip() print(f"Hello, {name}!") Starter input River Hint Use input().strip() to get the name. In the f-string change the greeting text and remove the exclamation mark. Case 1. Try the sample Input Comets Expected output Team: Comets Case 2. Trims both ends Input Night Owls Expected output Team: Night Owls Stretch Read a second line with a mascot name, then print the team and mascot in one sentence. Reflect What would you see if you left out strip()? Check your prediction strip() trims them. strip() removes leading and trailing whitespace from the value it returns. ────────────────────────────────────── 6. The Club Pass Desk · Price a Ticket Order Convert a line of text into a number before doing arithmetic. Lesson files · lessons/input-and-decisions/numbers-from-input Before you start - Read one line with input(). - Multiply a count by a fixed amount. By the end - Use int(input()) to read a whole number for arithmetic. - Explain why multiplying the text "3" gives a different result from multiplying the number 3. Where you can use it Work out the cost of an activity order. Read the number of items as a whole number so you can multiply it by the price. When you type 3, input() gives Python the text "3". In int(input()), Python reads a line first and then int() converts it to a whole number. The number 3 times 5 gives 15. The text "3" times 5 gives "33333". Try a whole number in Program input. If you enter the word three, the conversion raises a ValueError. In the debugging module you will give the user a helpful response when that happens. Predict What does the example print for 0? - 5 - 0 Worked example (example.py) count = int(input()) print(count * 5) Example input 3 Example result 15 Read the number of tickets and print the total at 12 rand each. For three, print Total: R36. Starter program (starter.py) count = int(input()) print(count * 5) Starter input 3 Hint Make count an int first. Then put the calculated price after the R in an f-string. Case 1. Try the sample Input 3 Expected output Total: R36 Case 2. Zero tickets Input 0 Expected output Total: R0 Stretch Read a ticket price on a second line and use both numbers in your total. Reflect How is the text "3" different from the number 3 in a multiplication? Check your prediction 0 The number read into count is multiplied by the ticket price. ────────────────────────────────────── 7. The Club Pass Desk · Open the Right Door Use a comparison and indentation to control which instructions run. Lesson files · lessons/input-and-decisions/booleans-and-if Before you start - Read a whole number with int(input()). - Recognise the values True and False. By the end - Use if and else to choose one message from a comparison. - Test the cutoff and the score just below it. Where you can use it Show a different message when a player reaches the score needed for the next level. Test the score that opens the level. A comparison such as score >= 5 gives True when the score is 5 or higher. The colon ends the if line, and the lines indented under it run when the condition is True. Put else at the same indentation level as if. Its own indented lines run when the condition is False. To check another condition in the same chain, add an elif between if and else. The next lesson uses that pattern for three pass tiers. Predict Does >= 5 include a score of exactly 5? - Yes. - No. Worked example (example.py) score = int(input()) if score >= 5: print("Open") else: print("Keep practising") Example input 5 Example result Open Print Go! when the score is at least 8. Print Try again. for a smaller score. Starter program (starter.py) score = int(input()) if score >= 5: print("Open") else: print("Keep practising") Starter input 5 Hint Put exactly one print in each branch. Use >= so the boundary is included. Case 1. Try the sample Input 8 Expected output Go! Case 2. Just below the cutoff Input 7 Expected output Try again. Stretch Add a separate message for 10 or more using if, elif and else. Reflect Which output tells you that 7 and 8 fell into different branches? Check your prediction Yes. The equals part of >= includes the boundary. ────────────────────────────────────── 8. The Club Pass Desk · Build a Club Pass Adviser Choose one tier from three and verify both cutoffs. Lesson files · lessons/input-and-decisions/club-pass-adviser Before you start - Use if and else to choose a message. - Use >= to include the cutoff in a comparison. By the end - Use if, elif and else to select one tier. - Trace which conditions get checked at each cutoff. - Explain why the highest cutoff comes first. Where you can use it Assign bronze, silver or gold badges for a reading challenge. Check the highest goal first so each reader gets the right badge. Python checks the conditions in an if/elif/else chain from top to bottom. It runs the first branch whose condition is True. The else block runs if all the conditions are False. A score of 10 passes both the Gold and Silver cutoffs. Check the highest cutoff first so the Gold branch gets the score. Trace which comparisons happen for 4, 5 and 10 before you try the code. Predict What happens if you check >= 5 first for a score of 10? - Python automatically picks the highest tier. - The Silver branch runs first. Worked example (example.py) points = int(input()) if points >= 5: print("Silver or higher") else: print("Bronze") Example input 5 Example result Silver or higher Read a non-negative whole number of points. Print Bronze for 0–4, Silver for 5–9, and Gold for 10 and above. Print only the tier name. Starter program (starter.py) points = int(input()) if points >= 5: print("Silver or higher") else: print("Bronze") Starter input 5 Hint Start with if points >= 10. Try elif points >= 5 next and put Bronze in else. Case 1. Try the sample Input 5 Expected output Silver Case 2. Bronze boundary Input 4 Expected output Bronze Case 3. Gold boundary Input 10 Expected output Gold Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Invent a Platinum threshold and add two tests on either side of it. Reflect Why does a Gold score also pass the Silver comparison? Check your prediction The Silver branch runs first. An if/elif/else chain runs its first matching branch. ────────────────────────────────────── 9. Measure and Plan with Numbers · Convert a Measurement Read a decimal measurement and express it in a different unit. Lesson files · lessons/numeric-tools/convert-a-measurement Before you start - Convert input to a whole number with int(). - Multiply a count by a fixed amount and label the result. By the end - Use float(input()) to read a measurement with a decimal point. - Explain why the number grows when the unit changes from litres to millilitres. - Test the conversion with a fraction of a litre and with zero. Where you can use it Compare a plant’s height with a chart that uses centimetres. Convert a reading in metres first so the numbers use the same unit. A measuring tape might show 1.75 metres. Use a decimal point when you enter a fractional measurement like 1.75. float(input()) reads the line and converts the text to a number you can multiply. There are 100 centimetres in a metre, so multiply the measurement in metres by 100 to get the value in centimetres. Include the unit in each variable name and in the output. The next lesson shows how to control how many decimal places appear. Predict What happens to the number when you change from metres to centimetres? - It becomes 100 times as large. - It becomes 100 times as small. Worked example (example.py) metres = float(input()) centimetres = metres * 100 print(f"{centimetres} cm") Example input 1.75 Example result 175.0 cm Read one non-negative decimal measurement in litres. Convert it to millilitres and print the number followed by a space and mL. Use Python’s default float display, so 1.25 L appears as 1250.0 mL. Starter program (starter.py) litres = float(input()) # Calculate the amount in millilitres here. print(f"{litres} L") Starter input 1.25 Hint There are 1000 millilitres in a litre. Store the converted number in a new variable and use it in the f-string. Case 1. Try the sample Input 1.25 Expected output 1250.0 mL Case 2. Part of a litre Input 0.125 Expected output 125.0 mL Case 3. Empty measure Input 0 Expected output 0.0 mL Stretch Divide the millilitres by 1000 to convert back to litres. Compare the result with your starting measurement. Reflect How do your variable names tell you which number to print? Check your prediction It becomes 100 times as large. Each metre contains 100 centimetres, so the same length needs a larger number of centimetres. ────────────────────────────────────── 10. Measure and Plan with Numbers · Show the Right Precision Calculate a share and display it to a fixed number of decimal places. Lesson files · lessons/numeric-tools/show-decimal-places Before you start - Read a decimal with float(input()). - Put a result in an f-string. By the end - Use division to calculate equal shares. - Use :.2f in an f-string to show two decimal places. - Explain what happens to the stored value when you format its display. Where you can use it Split juice among several cups and print an easy-to-read label. Keep the full amount per cup if you need it again for a bigger batch. Use / to divide a quantity among equal shares. With 1.25 litres and four trays, each tray gets 1.25 / 4, which gives 0.3125 litres. In an f-string, {distance_m:.2f} displays distance_m rounded to two decimal places. It adds zeroes when needed, so 1.0 displays as 1.00. The stored value stays the same. Use that value for any later calculations and format it when you print. Predict What does the second print display? - 1.18 m - 1.19 m Worked example (example.py) distance_m = 1.1875 print(distance_m) print(f"{distance_m:.2f} m") Example result 1.1875 1.19 m Read the total litres on the first line and a positive whole number of seed trays on the second. Divide the water evenly and print the amount for each tray to two decimal places. Enter 1.25 and 4 to get 0.31 L per tray. Starter program (starter.py) total_litres = float(input()) trays = int(input()) print(f"{total_litres} L to share") Starter input 1.25 4 Hint Divide the litres by the tray count. Put :.2f after the name of the result inside the braces of your f-string. Case 1. Try the sample Input 1.25 4 Expected output 0.31 L per tray Case 2. One litre each Input 2 2 Expected output 1.00 L per tray Case 3. No water to share Input 0 3 Expected output 0.00 L per tray Stretch For the sample input, also show the amount in millilitres per tray to one decimal place. Convert the stored share and compare it with a conversion of the displayed 0.31 L. Reflect Where would you make the label show three decimal places? Check your prediction 1.19 m To display two decimal places, Python rounds 1.1875 to 1.19. ────────────────────────────────────── 11. Measure and Plan with Numbers · Check a Measured Range Use an inclusive range to decide whether a numeric reading can be used. Lesson files · lessons/numeric-tools/guard-a-measurement Before you start - Read a decimal measurement with float(input()). - Use if and else to handle two outcomes. By the end - Use a chained comparison to check both ends of a range. - Test an exact endpoint and a reading outside the range. Where you can use it Check a game’s volume setting before using it. Try both ends of the allowed range and a setting just outside it. A grow light's timer accepts settings from 2 to 8 hours, including the two ends. In 2 <= hours <= 8, the first comparison checks that the reading is at least 2. The second checks that it is at most 8. Both need to pass. Trace the two comparisons for 2, 8 and 8.1. Use the range check after converting the input to a number. A later lesson handles replies that fail conversion, such as the word eight. Predict What does the timer program print at exactly 8 hours? - Timer ready - Check the setting Worked example (example.py) hours = float(input()) if 2 <= hours <= 8: print("Timer ready") else: print("Check the setting") Example input 8 Example result Timer ready Read a jug’s volume in litres as one decimal number. Print In range for readings from 0 to 2 litres inclusive. For readings outside that range, print Out of range. Starter program (starter.py) litres = float(input()) # Decide whether the reading fits the marked range. print("In range") Starter input 2.01 Hint Give the if a lower and an upper comparison. Use else for readings that fail either comparison. Case 1. Try the sample Input 2.01 Expected output Out of range Case 2. Exactly full Input 2 Expected output In range Case 3. Negative reading Input -0.01 Expected output Out of range Stretch Try a reading of zero. Then add an elif to give different messages for a negative reading and a reading above 2. Reflect Which comparison rules out a negative reading? Check your prediction Timer ready The second <= allows a reading equal to 8. ────────────────────────────────────── 12. Measure and Plan with Numbers · Build a Water Refill Planner Check two measurements and calculate how many bottle fills cover a water target. Lesson files · lessons/numeric-tools/water-refill-planner Before you start - Check whether a number falls within inclusive limits. - Divide to convert a quantity or find an equal share. - Format a decimal result with two places. By the end - Use and to check the target and capacity before dividing. - Use ceil() to count a partial fill. - Test a partial fill, an exact fit and an invalid capacity. Where you can use it Plan how many boxes you need for art supplies. Divide the number of kits by the box capacity and count a partly filled box too. To carry 1250 mL in a 500 mL bottle, a gardener needs two full fills and one partial fill. The division gives 2.5. A call to ceil(2.5) counts 3 fills, and ceil(2.0) gives exactly 2. Keep the line from math import ceil at the top of the program so you can use ceil(). Check each range and give the two results names. The condition target_ok and bottle_ok is True only when both checks pass. Divide in that branch to avoid dividing by zero. To display the amount planned, divide the target in millilitres by 1000 to convert to litres, then show two decimal places. Predict How many boxes do you need if you change tiles to 12? - 3 - 2 Worked example (example.py) from math import ceil tiles = 13 tiles_per_box = 6 boxes = ceil(tiles / tiles_per_box) print(f"Boxes needed: {boxes}") Example result Boxes needed: 3 Read two whole numbers on separate lines. The first is the water target in mL from 0 to 10000 inclusive. The second is the bottle capacity in mL from 250 to 2000 inclusive. If either value is outside its range, print Out of range. For valid inputs, count all fills including a partial final fill. Print Fills needed: 3 and Water planned: 1.25 L on separate lines for a target of 1250 and a capacity of 500. Show the target in litres to two decimal places. Starter program (starter.py) from math import ceil target_ml = int(input()) bottle_ml = int(input()) # Check the measurements before calculating the fills. print(f"{target_ml} mL requested") Starter input 1250 500 Hint Check the ranges first. In the valid branch, apply ceil() to the target divided by the capacity and use a separate conversion to get litres. Case 1. Try the sample Input 1250 500 Expected output Fills needed: 3 Water planned: 1.25 L Case 2. Exact fills at the limits Input 10000 2000 Expected output Fills needed: 5 Water planned: 10.00 L Case 3. Zero capacity Input 750 0 Expected output Out of range Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Try a zero target. Then report the millilitres in the last fill whenever the plan needs at least one fill. Test one full and one partial last fill. Reflect Why does a partial last fill count as a whole fill in your report? Check your prediction 2 Twelve tiles fill two boxes exactly. ceil(2.0) gives 2. ────────────────────────────────────── 13. Game Loops · Count Down to Launch Use a range to generate a sequence and explain its stopping rule. Lesson files · lessons/loops-and-games/for-and-range Before you start - Use indentation to group instructions under an if. - Read a whole number with int(input()). By the end - Use for and range() to count backward. - Use indentation to make the launch message run once. - Predict whether the stop value will appear in the countdown. Where you can use it Count down the last few seconds of a game and show a start message when the countdown ends. A for loop takes one value at a time from a sequence. In range(3, 0, -1), start at 3 and subtract one each time. The loop stops before 0, so the indented print runs for 3, 2 and 1. The print after the loop runs once when the countdown is over. Start from 0 to try a range with zero steps to print. Predict Is 0 printed by the example loop? - No. - Yes. Worked example (example.py) for number in range(3, 0, -1): print(number) print("Launch!") Example result 3 2 1 Launch! Read a starting number. Count down from that number to 1, then print Blast off! on its own line. At 0, launch straight away. Starter program (starter.py) start = int(input()) for number in range(3, 0, -1): print(number) print("Launch!") Starter input 5 Hint Replace the first value in range with start. Leave the announcement outside the loop. Case 1. Try the sample Input 5 Expected output 5 4 3 2 1 Blast off! Case 2. Short countdown Input 2 Expected output 2 1 Blast off! Case 3. Launch now Input 0 Expected output Blast off! Stretch Count down by twos from 10, and predict the last number. Reflect Why does indenting the final print change the announcement? Check your prediction No. range stops before its stop value, even when counting backwards. ────────────────────────────────────── 14. Game Loops · Keep a Running Score Use an accumulator to combine one new value per round. Lesson files · lessons/loops-and-games/totals-and-counters Before you start - Use for and range() to repeat an action. - Read a whole number with int(input()). By the end - Use a variable to collect a total across repeated input. - Trace how the total changes after each reading, including zero. Where you can use it Add up the points from several basketball rounds. Read one score per round and print the total after the last one. Use range(3) to get the values 0, 1 and 2 and make the loop run three times. In this example the loop number counts the rounds. The program reads a new score during each round. Set total = 0 before the loop, then add each score to that same total. The update total += points means total = total + points. Trace the example's total after it reads 5, then 0, then 7. Predict What happens after the second input, which is 0? - The total resets to 0. - The total stays at 5. Worked example (example.py) total = 0 for round_number in range(3): total += int(input()) print(f"Total: {total}") Example input 5 0 7 Example result Total: 12 Read four scores and print their sum as Score: followed by the number. Starter program (starter.py) total = 0 for round_number in range(3): total += int(input()) print(f"Total: {total}") Starter input 5 0 7 Hint Put total = 0 above the loop, and change the loop to repeat four times. Case 1. Try the sample Input 1 2 3 4 Expected output Score: 10 Case 2. Zero points Input 0 0 0 0 Expected output Score: 0 Stretch Read a round count first so the program can handle a tournament of any length. Reflect What would happen if you indented total = 0 inside the loop? Check your prediction The total stays at 5. Adding zero keeps the previous total. ────────────────────────────────────── 15. Game Loops · Give a Loop an Exit Make a while loop stop when a value reaches its limit. Lesson files · lessons/loops-and-games/while-and-stop Before you start - Use a comparison to make a yes-or-no decision. - Update a running total inside a loop. By the end - Use while to repeat while a condition is true. - Trace the update that makes the loop stop. - Test an input for which the loop runs zero times. Where you can use it Play a simple game while the player has energy left. Lower the energy on each turn and show the end message after it reaches zero. A while loop checks its condition before each trip through the indented body. Start with fuel at 2. Each fuel -= 1 update subtracts one. When fuel reaches 0, fuel > 0 becomes False and the program continues with the line after the loop. If a loop keeps running, press Stop. Trace the starting value, the condition and the update to find out what keeps it going. Predict Which line makes the condition eventually false? - fuel -= 1 - print("Engine off.") Worked example (example.py) fuel = 2 while fuel > 0: print(f"Fuel: {fuel}") fuel -= 1 print("Engine off.") Example result Fuel: 2 Fuel: 1 Engine off. Read a starting battery number. While it is above zero, print Battery: with the current value and lower it by one. Then print Power down. Starter program (starter.py) fuel = 2 while fuel > 0: print(f"Fuel: {fuel}") fuel -= 1 print("Engine off.") Hint The final print belongs outside the loop. Test the case where the starting battery is already 0. Case 1. Try the sample Input 2 Expected output Battery: 2 Battery: 1 Power down. Case 2. Already empty Input 0 Expected output Power down. Stretch Predict and test the result of draining two units per round. Reflect How can you tell from the code that the loop will stop? Check your prediction fuel -= 1 The subtraction is inside the loop, so each repetition moves fuel toward zero. ────────────────────────────────────── 16. Game Loops · Build Number Quest Make a three-guess game with higher/lower feedback and an early win. Lesson files · lessons/loops-and-games/number-quest Before you start - Use a while loop that checks a changing value. - Use if, elif and else to choose one result. - Use and to require two conditions to be true. By the end - Use a counter and a True or False value to track the game. - Test a win on the first guess and a loss after three guesses. - Explain why the game skips the loss message after a win. Where you can use it Add a fixed number of tries to a word puzzle. Track how many are left and finish as soon as the player solves it. The worked example reads one guess. The equality test guess == secret gives True when the guess matches. For a full round, start with attempts_left at 3 and won at False. Use while attempts_left > 0 and not won to keep offering guesses. The expression not won is True while won is False. Inside the loop, subtract one attempt after each guess and set won to True when the player is correct. After the loop, use if not won to print the losing message. Trace attempts_left and won for a first-guess win and a run of three wrong guesses. Predict What should the game do immediately after a correct guess? - Require every remaining guess. - Finish the round. Worked example (example.py) secret = 7 print("Guess 1 to 9.") guess = int(input()) if guess == secret: print("Correct!") else: print("Try again.") Example input 2 Example result Guess 1 to 9. Try again. Print Guess 1 to 9. before each guess. Give at most three guesses at the secret 7. Print Correct! for a win, Too low. for a low guess and Too high. for a high one. If all guesses are wrong, print Out of tries. The number was 7. Starter program (starter.py) secret = 7 print("Guess 1 to 9.") guess = int(input()) if guess == secret: print("Correct!") else: print("Try again.") Starter input 2 Hint Track attempts_left and won. Read a guess and subtract one attempt inside while attempts_left > 0 and not won. Case 1. Try the sample Input 2 9 7 Expected output Guess 1 to 9. Too low. Guess 1 to 9. Too high. Guess 1 to 9. Correct! Case 2. Win on the first turn Input 7 Expected output Guess 1 to 9. Correct! Case 3. Use all three tries Input 2 4 8 Expected output Guess 1 to 9. Too low. Guess 1 to 9. Too low. Guess 1 to 9. Too high. Out of tries. The number was 7. Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Make the attempt limit a named setting and try a two-turn game with a new secret. Reflect Which condition stops the program in each of the two endings? Check your prediction Finish the round. The loop condition can combine attempts left with whether the player won. ────────────────────────────────────── 17. Message Lab · Read a Call Sign Use an index to find one character and a slice to take part of a string. Lesson files · lessons/strings-and-messages/positions-and-slices Before you start - Read a line of text with input(). - Predict where a range() stops. By the end - Use an index to get one character and a slice to get part of a string. - Use upper() on the sliced text. - Predict what the slice gives you when the call sign contains one character. Where you can use it Make a short badge code from the start of a chosen name. A slice can still produce a code when the name has only one letter. Python numbers string positions from zero. In ORBIT-42, O is at position 0, R is at 1 and B is at 2. signal[0] gives O. The slice signal[:3] takes the first three characters, stopping before position 3. Put .upper() after a slice to make its letters uppercase. For a one-character input such as q, [:2] returns the one available character and .upper() turns it into Q. Predict What does signal[:3] contain? - ORB - ORBI Worked example (example.py) signal = "ORBIT-42" print(signal[0]) print(signal[:3]) Example result O ORB Read a call sign and print its first two characters in uppercase. Starter program (starter.py) signal = "ORBIT-42" print(signal[0]) print(signal[:3]) Hint Use input()[:2].upper(). Apply the slice before printing. Case 1. Try the sample Input golden-1 Expected output GO Case 2. One-character call sign Input q Expected output Q Stretch Try signal[-2:] and explain what the negative start means. Reflect How many characters does [:2] request? Check your prediction ORB Positions 0, 1 and 2 are included. ────────────────────────────────────── 18. Message Lab · Assemble a Team Tag Turn words into a list and combine them with a separator. Lesson files · lessons/strings-and-messages/split-and-join Before you start - Read text that contains extra spaces. - Change the letter case of text with upper(). By the end - Use split() to get the words from a line with uneven spaces. - Use join() to put an underscore between each pair of words. - Test a tag made from a single word. Where you can use it Make a consistent team tag from names people type. Split the words and join them with underscores so stray spaces give the same tag. With empty parentheses, split() breaks text into words at whitespace such as spaces or tabs. It keeps the words in order in a list, with every run of spaces serving as one break. For the worked example, that gives ["Red", "Comet"]. In "-".join(words), the hyphen is the separator. Python puts it between the words. Use "_" as the separator for the tag and .lower() on the original line to make the tag lowercase. Predict How many hyphens appear between Red and Comet? - Three. - One. Worked example (example.py) words = " Red Comet ".split() print("-".join(words)) Example result Red-Comet Read a team name and make a lowercase tag with underscores between words. Starter program (starter.py) words = " Red Comet ".split() print("-".join(words)) Hint Clean the case with lower(), use split(), then join the words with "_". Case 1. Try the sample Input Red Comet Club Expected output red_comet_club Case 2. A single word Input Eagle Expected output eagle Stretch Display both the clean tag and the number of words in the original name. Reflect Why is split followed by join useful when a name contains extra spaces? Check your prediction One. split() first finds the two words. join() then inserts one hyphen between them. ────────────────────────────────────── 19. Message Lab · Measure a Message Loop over characters and count the ones that meet a condition. Lesson files · lessons/strings-and-messages/count-characters Before you start - Use a for loop to visit values in order. - Update a total inside a loop. - Use if to run a line only when its condition is true. By the end - Use a for loop to visit every character in a string. - Use isdecimal() to decide when to increase a digit count. - Trace the count for a message with both letters and digits. Where you can use it Check how many digits are in a locker code. Visit each character and count digits even when the code mixes letters and numbers. A for loop over a string visits one character at a time. The example lowercases the word and uses char in "aeiou" to test whether each character appears among the five vowels. Add one to the count each time that test is true. For the digit challenge, use char.isdecimal() as the test. It returns True when the character is a decimal digit, such as 7. In B2 T17, the counter increases at 2, 1 and 7. Predict How does the example handle an uppercase vowel? - It lowercases before testing. - It skips uppercase letters. Worked example (example.py) count = 0 for char in "BEacon".lower(): if char in "aeiou": count += 1 print(count) Example result 3 Read a message and print the number of digits. Use char.isdecimal() on each character. Starter program (starter.py) count = 0 for char in "BEacon".lower(): if char in "aeiou": count += 1 print(count) Hint Keep the counter outside the loop. Increase it inside the if. Case 1. Try the sample Input B2 T17 Expected output 3 Case 2. No digits Input All clear Expected output 0 Stretch Add a second counter for spaces. Reflect What is the difference between counting digits and converting an entire message to int? Check your prediction It lowercases before testing. lower() turns E into e, which appears in the string of vowels. ────────────────────────────────────── 20. Message Lab · Build a Radio Message Cleaner Normalise a free-text message and produce a consistent radio summary. Lesson files · lessons/strings-and-messages/radio-message-cleaner Before you start - Use split() and join() to rebuild a line of text. - Use upper() to change the case of letters. - Choose a message with if and else. By the end - Use len() on a list of words to find the word count. - Use an empty-list check to give blank messages a clear label. - Test the cleaner with uneven spaces and with only spaces. Where you can use it Clean a typed announcement before showing it on a club display. Keep one space between words and show a clear message for an empty announcement. Read the line, use upper() to change its letters, then use split() to get the words. Use len(words) to count the items in that list. When the list has words, " ".join(words) places one space between each pair. A line of spaces gives split() an empty list. The condition if words is True only when the list has at least one item. Use its else branch to give an empty message a readable label. Predict What list comes from splitting a whitespace-only message? - A list with one space. - An empty list. Worked example (example.py) words = input().upper().split() print(" ".join(words)) Example input ready to land Example result READY TO LAND Clean the message to uppercase with one space between words. Print Words: followed by the word count. Then print Message: followed by one space and the cleaned message. If there are zero words, print Message: (empty) instead. Starter program (starter.py) words = input().upper().split() print(" ".join(words)) Starter input ready to land Hint Use len(words) for the count. Use an if to choose between " ".join(words) and "(empty)". Case 1. Try the sample Input ready to land Expected output Words: 3 Message: READY TO LAND Case 2. Whitespace only Input Expected output Words: 0 Message: (empty) Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Limit a call sign summary to the first four words and explain what the slice does. Reflect Which part of the program removes the extra spaces, and which part combines the words? Check your prediction An empty list. Default split() removes whitespace separators and returns only the words. ────────────────────────────────────── 21. The Club Library · Build a Reading Queue Read a list position and add an item to the end of the list. Lesson files · lessons/lists-and-records/lists-and-indexes Before you start - Use an index to read a character from text. - Use len() to count the words in a list. By the end - Use append() to put a new title at the end of a list. - Use an index to read the first or last item. - Explain how appending an item changes the result of len(). Where you can use it Keep a queue of songs to practise. Append a new song and use an index to see which one is first or last. A list keeps values in order. Start the reading list with ["Star Map", "Moon Garden"]. Use titles[0] to read the first title and titles[-1] to read the last. The call titles.append("Sky Lab") changes the list by adding one title at the end. Now len(titles) gives 3, and titles[-1] gives Sky Lab. Predict Which title does titles[0] select? - Star Map - Sky Lab Worked example (example.py) titles = ["Star Map", "Moon Garden"] titles.append("Sky Lab") print(titles[0]) print(len(titles)) Example result Star Map 3 Read a title, add it to ["Star Map", "Moon Garden"], and print the final title and the list length. Starter program (starter.py) titles = ["Star Map", "Moon Garden"] titles.append("Sky Lab") print(titles[0]) print(len(titles)) Hint titles[-1] reads the last item. Use input() as the value to append. Case 1. Try the sample Input Night Atlas Expected output Night Atlas 3 Case 2. Another title Input Forest Map Expected output Forest Map 3 Stretch Print the first and last titles before and after adding a book. Reflect What index would you use for the second item? Check your prediction Star Map Position 0 is the first item. append() adds to the end. ────────────────────────────────────── 22. The Club Library · Find Books That Match Build a new list by keeping items that meet a condition. Lesson files · lessons/lists-and-records/filter-a-list Before you start - Use append() to add an item to a list. - Use lower() to make letters lowercase. - Use in to check whether a character appears in text. By the end - Use a loop to collect matching titles in a new list. - Use lowercase copies when you compare text. - Test a query that matches two titles and a query that matches none. Where you can use it Find the workshop titles that contain a search word. Keep the original wording in the results so people see the proper titles. Start with an empty result list. Check each title and append the original title when it matches. Use lowercase versions of both the search word and the title in the test so that STAR and star give the same results. An in test looks for the search text anywhere in the title. After the loop, join the matches with " / ". Use an else branch to tell the reader when the result list is empty. Predict Which title fails the condition? - Star Atlas - Moon Garden Worked example (example.py) matches = [] for title in ["Star Map", "Moon Garden", "Star Atlas"]: if "Star" in title: matches.append(title) print(" / ".join(matches)) Example result Star Map / Star Atlas Read one non-empty search word. Search the three example titles using lowercase comparisons. Print the matching titles in their original case, separated by / with one space on each side. Print No matches. if the list is empty. Starter program (starter.py) matches = [] for title in ["Star Map", "Moon Garden", "Star Atlas"]: if "Star" in title: matches.append(title) print(" / ".join(matches)) Hint Use word in title.lower() and check whether matches contains any items before calling join(). Case 1. Try the sample Input STAR Expected output Star Map / Star Atlas Case 2. No match Input ocean Expected output No matches. Stretch Try requiring the search word at the start of the title with startswith(). Reflect Why does the original list still have three titles after filtering? Check your prediction Moon Garden Moon Garden does not contain Star. ────────────────────────────────────── 23. The Club Library · Give Each Book a Record Use named dictionary keys to read and update related information. Lesson files · lessons/lists-and-records/dictionary-records Before you start - Store text and True or False under names. - Read a list item with square brackets. By the end - Use a dictionary to store several details about one book. - Use a key to add and then read the room field. - Explain when get() returns its fallback value. Where you can use it Store a borrowed game’s name, shelf and availability together. Read a detail by its key and update the shelf when the game moves. A dictionary connects a key to each value. In the example the key "title" points to the text "Sky Lab", and the key "available" points to True. Use book["title"] to get the title by its key. When room might be missing, book.get("room", "Main") returns Main as a fallback. To store a room, use an assignment such as book["room"] = "Media Room". After the assignment, the record has a room key you can read. Predict Why does the second line say Main? - room is missing, so get uses its default. - Every dictionary has a room key. Worked example (example.py) book = {"title": "Sky Lab", "available": True} print(book["title"]) print(book.get("room", "Main")) Example result Sky Lab Main Read a room name and store it in the book record. Print the title and then the room. Starter program (starter.py) book = {"title": "Sky Lab", "available": True} print(book["title"]) print(book.get("room", "Main")) Hint Use book["room"] = input() after creating the dictionary. Case 1. Try the sample Input Media Room Expected output Sky Lab Media Room Case 2. Move the book Input Café Corner Expected output Sky Lab Café Corner Stretch Add a player-friendly label that shows whether the book can be borrowed. Reflect When is a missing key with a default useful? Check your prediction room is missing, so get uses its default. get returns the supplied default for a missing key. ────────────────────────────────────── 24. The Club Library · Build a Club Library Report Filter a list of records and handle an empty result. Lesson files · lessons/lists-and-records/club-library Before you start - Read and update a value in a dictionary. - Use a loop and append() to collect matching items. - Count a list with len(). By the end - Use a loop to check availability in each book record. - Use the filtered list to print the count and titles. - Test a catalogue with some available books and one with none. Where you can use it Make a list of sports gear the class can borrow today. Read each item’s availability, then show the number of choices and their names. A catalogue is a list of book dictionaries. On each trip through the loop, book holds one dictionary. When the input is closed, set book["available"] to False before checking that book's availability. Use a separate if to read the availability flag. Append the title when the flag is True. Count and print the selected titles after the loop so the count describes the entire result. Predict What value should go into the result list for each available book? - The number of all books. - Its title. Worked example (example.py) books = [{"title": "Sky Lab", "available": True}] for book in books: print(book["title"]) Example result Sky Lab Use the starter catalogue. Input browse reports current availability. Input closed sets each book unavailable first. Print Available: and the count, then one line per available title in catalogue order. Starter program (starter.py) books = [ {"title": "Sky Lab", "available": True}, {"title": "Moon Garden", "available": False}, {"title": "Star Map", "available": True}, ] mode = input().strip() print(f"Available: {len(books)}") Starter input browse Hint Apply the closed update before filtering, then use if book["available"] for each record. Case 1. Try the sample Input browse Expected output Available: 2 Sky Lab Star Map Case 2. Closed catalogue Input closed Expected output Available: 0 Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Add a reserved flag and decide whether reserved books should appear. Reflect What evidence shows that the tool handles a catalogue with zero available books? Check your prediction Its title. A list of titles can be counted and printed without carrying the extra fields. ────────────────────────────────────── 25. The Scoreboard Workshop · Reuse a Goal Chant Define a function once and run its body more than once. Lesson files · lessons/functions/define-and-call Before you start - Use print() to show a message. - Use indentation to group steps in a loop. By the end - Use def to give a group of instructions a name. - Use two or more calls to repeat the same function body. - Trace which lines run when Python reaches each call. Where you can use it Give a game one function for its victory message. Call it whenever a player wins so every win gets the same message. Use def cheer(): to name the function cheer. Its indented body contains the instructions to run each time you call it. Write cheer() on a line outside the body to call the function. When Python reaches the call, it runs the indented print and then moves to the next instruction after the call. Count the call lines to predict how many chants you will see. Predict How many times does the indented print run? - Twice. - Three times. Worked example (example.py) def cheer(): print("Go Comets!") cheer() cheer() Example result Go Comets! Go Comets! Change the chant to Go Owls! and call the function three times. Starter program (starter.py) def cheer(): print("Go Comets!") cheer() cheer() Hint Keep one print in the function. Add a third call outside the indented body. Case 1. Try the sample Input (No input.) Expected output Go Owls! Go Owls! Go Owls! Stretch Make a second function for a celebration after the final call. Reflect Where do you edit the chant so every call uses the new words? Check your prediction Twice. The two calls execute the body. The definition sets up the function. ────────────────────────────────────── 26. The Scoreboard Workshop · Turn a Rule into a Function Pass an argument and use a returned result in the caller. Lesson files · lessons/functions/parameters-and-return Before you start - Define a function with def and call it by name. - Multiply two numbers to calculate a total. By the end - Use a parameter to receive the star count. - Use return to give the calculated reward back to the caller. - Explain how the caller uses that result. Where you can use it Calculate the cost of a supply order in a function. Return the amount so another part of the program can add it to the bill. The function reward has a parameter named stars. In the call reward(3), the number 3 is the argument. During that call, stars holds 3. The return line sends stars * 2 back to the caller. In print(reward(3)), reward(3) produces 6, and then the outer print shows it. You could also store the result with coins = reward(3) and use coins in another calculation. Predict What could a caller do with reward(3)? - Only display it. - Save or combine the result. Worked example (example.py) def reward(stars): return stars * 2 print(reward(3)) Example result 6 Make reward(stars) return three coins for each star. Read a star count and print the returned value. Starter program (starter.py) def reward(stars): return stars * 2 print(reward(3)) Hint Put the multiplication in the function and the input and print outside. Case 1. Try the sample Input 4 Expected output 12 Case 2. Zero stars Input 0 Expected output 0 Stretch Add a second parameter for the number of coins to award per star. Reflect What would change if you replaced return with print and kept print(reward(...))? Check your prediction Save or combine the result. The caller receives the number 6 and can use it like any other number. ────────────────────────────────────── 27. The Scoreboard Workshop · Separate Input from Calculation Write a function that can be tested with values supplied by any caller. Lesson files · lessons/functions/separate-roles Before you start - Pass a number to a function and use its returned value. - Read a whole number and put a result in a label. By the end - Use one function for the calculation and put input and display in the calling code. - Test the calculation with several supplied counts, including zero. Where you can use it Put a trip time calculation in a function. Call it with example stop counts while you test the rule, then use it with a traveller’s input. Give travel_minutes the numbers it needs as arguments and return the result. A call such as travel_minutes(3, 5) gives 15 without reading input. Put input and the f-string in the code that calls the function. This gives you one place to change the calculation and a separate place to change how the result looks. Predict Which part could run in a test without asking for input? - travel_minutes - int(input()) Worked example (example.py) def travel_minutes(stops, minutes_per_stop): return stops * minutes_per_stop stops = int(input()) print(f"Minutes: {travel_minutes(stops, 5)}") Example input 3 Example result Minutes: 15 Write trip_minutes(stops) with four minutes per stop and a fixed two-minute setup. Read stops and print Minutes: followed by the result. Starter program (starter.py) def travel_minutes(stops, minutes_per_stop): return stops * minutes_per_stop stops = int(input()) print(f"Minutes: {travel_minutes(stops, 5)}") Starter input 3 Hint Return stops * 4 + 2. Put the f-string in the caller so the function produces a number. Case 1. Try the sample Input 3 Expected output Minutes: 14 Case 2. Setup with zero stops Input 0 Expected output Minutes: 2 Stretch Call the function with two different values in one program to compare the trips. Reflect Where would you change the output wording without touching the calculation? Check your prediction travel_minutes The calculation function receives everything it needs through arguments. ────────────────────────────────────── 28. The Scoreboard Workshop · Build a Tournament Points Calculator Implement a reusable scoring rule and test it on several records. Lesson files · lessons/functions/points-calculator Before you start - Pass numbers to a function and return a calculated result. - Keep input and printing in the code that calls the function. By the end - Use a function to combine wins and draws under one scoring rule. - Test the rule with a mixed result, only draws and zero games. Where you can use it Work out totals for several teams in a tournament. Send each team’s wins and draws to the same function so the rule stays consistent. Each win earns three points and each draw earns one. Calculate expected results by hand before editing the function. Two wins and one draw are worth 7. Three draws and no wins are worth 3. Zero games are worth 0. The starter adds wins and draws, which gives 3 for the first case. Put the scoring rule inside points_for and keep the caller's input and print steps. Run all three cases after your edit. Predict How many points should three draws give? - 9 - 3 Worked example (example.py) def points_for(wins, draws): return wins + draws wins = int(input()) draws = int(input()) print(f"Points: {points_for(wins, draws)}") Example input 2 1 Example result Points: 3 Correct points_for(wins, draws) to return three points per win and one per draw. Read wins and draws on separate lines and print Points: and the total. Starter program (starter.py) def points_for(wins, draws): return wins + draws wins = int(input()) draws = int(input()) print(f"Points: {points_for(wins, draws)}") Starter input 2 1 Hint Use wins * 3 to count the points from wins. How many points should the draws add? Case 1. Try the sample Input 2 1 Expected output Points: 7 Case 2. All draws Input 0 3 Expected output Points: 3 Case 3. Zero games Input 0 0 Expected output Points: 0 Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Use points_for for two teams and report which has the higher total. Reflect Why does the function accept wins and draws separately? Check your prediction 3 Each draw is worth one, while each win is worth three. ────────────────────────────────────── 29. Check the Library Shelves · Number What You Visit Use enumerate to get a position and a value on each trip through a loop. Lesson files · lessons/iteration-patterns/number-items-with-enumerate Before you start - Use a for loop to visit items in a list. - Use split() to make a list from a line of text. - Use len() to see whether a list is empty. By the end - Use enumerate() to get a label number and an item in the same loop. - Explain how two equal codes can get different numbers. - Test the label output with a line containing only spaces. Where you can use it Print a numbered list of projects for a class show. Start the labels at 1 and number every entry even if two projects have the same name. A plain for loop over a list gives you one item at a time. enumerate() gives you two things each time, a counter and the item. In for number, code in enumerate(books, start=1), Python assigns those two values to number and code. The counter starts at 0 by default. Use start=1 to number labels from 1 while the position of each item in the list stays the same. Try two items with the same code to see them get separate labels. Predict Which number would Studio get if you left out start=1? - 1 - 2 Worked example (example.py) rooms = ["Lab", "Studio"] for number, room in enumerate(rooms, start=1): print(f"Stop {number} - {room}") Example result Stop 1 - Lab Stop 2 - Studio Read a line of book codes separated by spaces. Print one label per code, starting at 1 and keeping the input order. For AT BR, print Shelf 1 - AT and Shelf 2 - BR on separate lines. For a line containing only spaces, print No books. Starter program (starter.py) books = input().split() for code in books: print(code) Starter input AT BR Hint Use split() to make a list of codes. Check len(books) before numbering the codes with enumerate(). Case 1. Try the sample Input AT BR Expected output Shelf 1 - AT Shelf 2 - BR Case 2. Repeated codes Input AT AT Expected output Shelf 1 - AT Shelf 2 - AT Case 3. Empty shelf Input Expected output No books Stretch Read the starting label number on a second line so one report can continue the numbering from another. Reflect What information does enumerate() give you when two items have the same value? Check your prediction 1 enumerate() starts at 0 by default. Lab would get 0 and Studio would get 1. ────────────────────────────────────── 30. Check the Library Shelves · Pair Two Lists Use zip to match items by position and catch incomplete pairs. Lesson files · lessons/iteration-patterns/pair-matching-lists Before you start - Use split() to read space-separated entries into a list. - Use len() to count the items in a list. - Use a for loop with two names to receive a number and a value. By the end - Use zip() to pair entries that share a position. - Use a length check before pairing. - Explain what zip() leaves out when one list is shorter. Where you can use it Pair equipment with peg labels from two ordered lists. Count both lists first so you can spot a missing label before assigning any pegs. zip(left, right) takes the first item from each list, then the second item from each and so on. Write for name, code in zip(names, codes) to give each half of a pair a name. Pairing depends on position, so swapping two codes changes the result. By default, zip() stops as soon as either list runs out. The example makes one pair. Craft has no code left to pair with it. Compare the lengths with !=, which gives True if the numbers differ. Put the pairing loop in the branch for equal lengths. Predict How many pairs does zip() produce in the example? - Two pairs. - One pair. Worked example (example.py) names = ["Chess", "Craft"] codes = ["A3"] for name, code in zip(names, codes): print(f"{name} - {code}") Example result Chess - A3 Read an equipment list on the first line and a peg label list on the second, using spaces between items on both lines. If the lengths differ, print Counts differ and skip the labels. Otherwise, print one line per pair. For net ball and P2 P1, print net goes on P2 and ball goes on P1 on separate lines. Starter program (starter.py) items = input().split() pegs = input().split() for item in items: print(item) Starter input net ball P2 P1 Hint Use != to compare the lengths. Put the zip() loop in the else block. Case 1. Try the sample Input net ball P2 P1 Expected output net goes on P2 ball goes on P1 Case 2. Extra peg Input rope P6 P7 Expected output Counts differ Case 3. Missing peg Input rope cone P6 Expected output Counts differ Stretch When there is a mismatch, also print the number of items and the number of pegs so the reader knows which list to check. Reflect How would an unchecked zip() hide a missing peg label? Check your prediction One pair. After the first pair the codes list has no items left, so zip() stops. ────────────────────────────────────── 31. Check the Library Shelves · Skip an Item or Stop Searching Use continue to skip an item and break to stop after finding a result. Lesson files · lessons/iteration-patterns/skip-or-stop-a-loop Before you start - Assign a starting value that can change inside a loop. - Number items with enumerate(). - Use if to check the value for one item. By the end - Use continue to skip one item and break to end a search. - Trace which shelf keeps its original number after a skip. - Test a list with no matching shelf. Where you can use it Find the first available spot in a row. Skip reserved spots and stop when you reach the first one you can use. Inside a loop, continue skips the rest of the current trip and lets the loop move on to the next item. break exits the loop immediately. The lines after the loop still run. In the example, the reader wants the first name with three letters or fewer. A dash stands for a blank space, so continue skips it before the length test. Give the result a default before the loop. When a name matches, replace the result and use break to keep the first match. For the shelf search, enumerate() gives each status its number as soon as the loop visits it. Skipping a closed shelf leaves the next shelf's original number in place. Predict Which name is printed if you remove the break line? - Ben - Uma Worked example (example.py) names = ["Nandi", "-", "Uma", "Ben"] chosen = "No match" for name in names: if name == "-": continue if len(name) <= 3: chosen = name break print(chosen) Example result Uma Read one line of shelf statuses separated by spaces. The possible statuses are closed, clear and check. Use continue to skip a closed shelf. Use break when you find the first check. For closed clear check check, print Review shelf 3. If there is no check, print All clear. Keep the original shelf numbers even when you skip a status. Starter program (starter.py) statuses = input().split() message = "All clear" for number, status in enumerate(statuses, start=1): print(f"Shelf {number} - {status}") print(message) Starter input closed clear check check Hint Use enumerate(statuses, start=1) and store a default message before the loop. After continue skips closed, status != "clear" detects a shelf to review. Case 1. Try the sample Input closed clear check check Expected output Review shelf 3 Case 2. First shelf needs review Input check closed clear Expected output Review shelf 1 Case 3. No review needed Input closed clear closed Expected output All clear Stretch Write a version that lists every shelf to review. Try the sample input and compare where the two programs stop. Reflect Which line lets the search move on from a closed shelf? Which line ends the search? Check your prediction Ben The search visits both short names. Ben meets the length rule and replaces Uma as the result. ────────────────────────────────────── 32. Check the Library Shelves · Build a Shelf Check Report Compare two lists and return a numbered report without changing the supplied records. Lesson files · lessons/iteration-patterns/shelf-check-report Before you start - Use zip() after checking that two lists have the same length. - Number items with enumerate() starting at 1. - Use append() to build a list of results. By the end - Use enumerate() and zip() together to compare numbered pairs. - Use a function to return a fresh list of report lines. - Test the difference between an empty slot and an incomplete scan list. Where you can use it Compare an instrument inventory with the items found during a check. Number the positions and tell the reader which item is missing or different. A librarian writes down which book code belongs in each slot, then scans the books in the same order. A dash marks an empty slot that the librarian checked. If the two lists have different lengths, the librarian needs to finish recording the slots before the program can compare them. Check the lengths first. If they differ, return a one-item list straight away. Otherwise use zip() to make the pairs, then enumerate(pairs, start=1) to number them. In the loop, number holds the slot number and (expected, scanned) gives each side of the pair a name. Build the report in a fresh list. Return it from the function and print its lines in the calling code. The original lists stay available for another report. Predict What does expected hold on the second trip through the loop? - CP - BK Worked example (example.py) expected_codes = ["AJ", "BK"] scanned_codes = ["AJ", "CP"] pairs = zip(expected_codes, scanned_codes) for number, (expected, scanned) in enumerate(pairs, start=1): print(f"Slot {number} - {expected} / {scanned}") Example result Slot 1 - AJ / AJ Slot 2 - BK / CP Enter the expected book codes on the first line and the scans on the second. Separate entries with spaces. A dash marks a checked slot with no book. Complete shelf_report(expected_codes, scanned_codes). If the lengths differ, return a list containing only Counts differ. For equal lengths, add one report line per slot. Use Slot 1 - OK for a match, Slot 2 - Missing for a dash, and Slot 3 - Expected CR, found DX for a mismatch. Use the actual slot number and codes in each line. Print the returned lines outside the function. Starter program (starter.py) def shelf_report(expected_codes, scanned_codes): # Build the report here. return ["Scan received"] expected_codes = input().split() scanned_codes = input().split() for line in shelf_report(expected_codes, scanned_codes): print(line) Starter input AT BR CR AT - DX Hint Start with the length check. For each numbered pair, decide whether it is missing, correct or mismatched. Append one line to a new report list. Case 1. Try the sample Input AT BR CR AT - DX Expected output Slot 1 - OK Slot 2 - Missing Slot 3 - Expected CR, found DX Case 2. All books in place Input CR AT CR AT Expected output Slot 1 - OK Slot 2 - OK Case 3. Missing scan record Input AT BR AT Expected output Counts differ Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Call the function again with the same expected list and a corrected scan. Compare the two reports and confirm that the expected list still has its original entries. Reflect How does your report tell an empty slot apart from a scan that was never recorded? Check your prediction BK zip() pairs by position. The first list supplies expected and the second list supplies scanned. ────────────────────────────────────── 33. The Repair Bench · Follow a Traceback Read an error name and identify the source line associated with it. Lesson files · lessons/debugging-and-tests/read-the-traceback Before you start - Assign a value to a variable. - Put a variable into an f-string. By the end - Use the last line of a traceback to find the error name. - Use the listed file and line number to locate the spelling mistake. - Test the fix by running the same program again. Where you can use it Find the cause of a crash after renaming a variable. Use the error type and line number to check where the old spelling still appears. When Python stops with an error, the traceback shows where the problem came up. Read the last line first for the type of error and its message. Then find the last mention of main.py and use its line number to find the code in the editor. A NameError means Python could not find a value under a name. Compare the name on the error line with the earlier assignment. Fix one spelling and run the same example again to check the repair. Predict Which error would print(singal) produce in the example? - NameError - ValueError Worked example (example.py) signal = "all clear" print(signal) Example result all clear Run the broken starter. Read the error, repair the name and make the console print Signal: all clear. Starter program (starter.py) signal = "all clear" print(f"Signal: {singal}") Hint Compare the string of letters in the assignment and in the f-string. Case 1. Try the sample Input (No input.) Expected output Signal: all clear Stretch Make a different spelling error and predict the line the traceback will point to. Reflect Write down the final line of the original traceback and what it meant. Check your prediction NameError singal has not been assigned. The nearby name signal is spelled differently. ────────────────────────────────────── 34. The Repair Bench · Recover from Bad Input Handle a failed conversion and distinguish it from an out-of-range number. Lesson files · lessons/debugging-and-tests/handle-value-error Before you start - Read a whole number with int(input()). - Use a comparison to check a number against two limits. - Read an error type from the last line of a traceback. By the end - Use try and except ValueError to handle a failed conversion. - Use the else branch to check a number that converted successfully. - Test a word, an allowed age and an age outside the range. Where you can use it Ask a player how many rounds to play. Give a helpful response when they type a word or enter a number outside the allowed range. Put int(input()) in the try block. If the conversion fails, the except ValueError block runs. Put the conversion on its own in try so you can see exactly which step the handler covers. The else aligned with try runs when the conversion succeeds. Inside that block, use if to check the number's range. For example, twelve fails conversion, while -1 converts and fails the range check. Predict Which branch receives the input three? - else - except ValueError Worked example (example.py) try: count = int(input()) except ValueError: print("Use a number.") else: print(f"Count: {count}") Example input three Example result Use a number. Read an age. If the reply cannot be converted to a whole number, print Use a number. If the number is below 0 or above 120, print Use 0 to 120. For a number in that range, print Age: followed by the age. Starter program (starter.py) try: count = int(input()) except ValueError: print("Use a number.") else: print(f"Count: {count}") Starter input three Hint Use a narrow try/except around conversion. In else, test 0 <= age <= 120. Case 1. Try the sample Input 12 Expected output Age: 12 Case 2. Non-number Input twelve Expected output Use a number. Case 3. Outside the range Input -1 Expected output Use 0 to 120. Stretch Try 120 and 121 to check the upper limit. Then try accepting up to two attempts before printing a final message. Reflect Why does -1 need a different response from twelve? Check your prediction except ValueError int cannot convert the word three into an integer. ────────────────────────────────────── 35. The Repair Bench · Write a Test That Can Fail Test a function using assert and describe the condition that failed. Lesson files · lessons/debugging-and-tests/assertions Before you start - Call a function and use its return value. - Read the error type and line number in a traceback. By the end - Use assert to compare a returned number with an expected result. - Use a failing test to locate a mistake in the calculation. - Explain why a test with zero alone can miss the mistake. Where you can use it Check a scoring rule after you edit it. Run assertions for a typical score and a boundary so you can catch a mistake right away. An assertion checks a condition you expect to be true. In assert double(4) == 8, Python calls double(4) and compares its result with 8. If the check fails, Python raises AssertionError and stops at that line. Choose expected results by hand. The starter's test of triple(4) catches a wrong multiplier. Its test of triple(0) checks that zero stays zero. Use assertions to test your functions. Use branches or exceptions to handle unexpected input from users. Predict What happens if double(4) returns 7? - Python stops at the failing assertion. - Python silently prints Tests passed. Worked example (example.py) def double(number): return number * 2 assert double(4) == 8 assert double(0) == 0 print("Tests passed") Example result Tests passed Run the starter and read its failing assertion. Repair triple so triple(4) is 12 and triple(0) is 0. Keep both checks and add an assertion for a negative number. The last line displays the result for the number in Program input. Starter program (starter.py) def triple(number): return number * 2 assert triple(4) == 12, "Four times three should be twelve" assert triple(0) == 0 print(f"Tripled: {triple(int(input()))}") Starter input 4 Hint Leave the expected results in the assertions as written. Change the return expression so the positive and zero tests pass. Case 1. Try the sample Input 4 Expected output Tripled: 12 Case 2. Different input Input -3 Expected output Tripled: -9 Stretch Add a message to one assertion after a comma. Temporarily change its expected result, read the message in the traceback, then restore the correct test. Reflect Which single bug would the normal case catch that the zero case would miss? Check your prediction Python stops at the failing assertion. A failed assertion raises AssertionError before the final print. ────────────────────────────────────── 36. The Repair Bench · Repair a Broken Quiz Reproduce a scoring bug, fix it and cover varied input with repeatable checks. Lesson files · lessons/debugging-and-tests/repair-a-quiz Before you start - Clean text with strip() and lower(). - Use if, elif and else to choose one result. - Run a failing case and inspect its result. By the end - Use a repeatable input to reproduce and check a bug fix. - Use a check for empty text after cleaning the reply. - Test a spaced correct answer, a blank answer and a wrong answer. Where you can use it Fix a spelling quiz that rejects an answer with extra spaces. Save that exact reply and try it again after the change. Run the starter with ORBIT surrounded by spaces. Write down the expected output and what actually appears. Clean the reply with strip() and lower(), then run that exact input again to check the fix. Spaces alone become an empty string after strip(). The condition if not answer is true when answer is empty. Put that case first, then check the answer key and handle any other reply. Try a blank answer and a wrong one as well as the repaired case. Predict What should happen when the answer is blank? - It is marked correct. - It gets an explicit response. Worked example (example.py) answer = input().strip().lower() print(answer == "orbit") Example input ORBIT Example result True Read one answer to the quiz. Trim and lowercase it. Print No answer. if empty, Correct! if it is orbit, and Try again. for any other answer. Starter program (starter.py) answer = input() if answer == "orbit": print("Correct!") else: print("Try again.") Starter input ORBIT Hint Use if not answer for the blank case before checking answer == "orbit". Case 1. Try the sample Input ORBIT Expected output Correct! Case 2. Blank answer Input Expected output No answer. Case 3. Wrong answer Input comet Expected output Try again. Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Write two assertions for a separate clean_answer(text) function. Reflect What was the first input that proved the starter had a bug? Check your prediction It gets an explicit response. A blank answer means the player has not supplied an answer. Detect it before comparing. ────────────────────────────────────── 37. Pocket Quiz Capstone · Write the Quiz Brief Turn a vague project idea into inputs, outputs and three examples. Lesson files · lessons/foundations-capstone/plan-a-tool Before you start - Store several strings in a list. - Use len() to count the items in a list. - Describe a test with its input and expected output. By the end - Use a short brief to record the quiz prompts and answer keys. - Use the list length to report the number of prompts. - Describe a test that will catch a problem with cleaning a reply. Where you can use it Plan a quiz for a school event. Write the questions, answer keys and a few example replies so a friend can check what should happen. A quiz brief tells a player what to enter, how the game scores it and what appears at the end. Give each question a prompt and an answer key. Pocket Quiz reads one answer per line and gives one point for a correct reply. Write down three ways to try the quiz. Include a correct reply, a reply with extra spaces and a blank reply. Record the result you expect for each case before you write the program. Predict Which is a stronger test description? - Input Mars, expect a correct answer. - See if it works. Worked example (example.py) questions = ["Name the red planet.", "What is 2 + 2?"] print(f"Questions: {len(questions)}") Example result Questions: 2 Write three quiz prompts with answer keys for your brief. Put the prompts in a Python list and use its length to print Questions: 3. Record one test from your brief in the reflection. Starter program (starter.py) questions = ["Name the red planet.", "What is 2 + 2?"] print(f"Questions: {len(questions)}") Hint Add a third string to the list. Let len() count the questions. Case 1. Try the sample Input (No input.) Expected output Questions: 3 Stretch Ask someone to read your tests and predict the score using only your brief. Reflect Which of your planned cases would catch a bug in input cleaning? Check your prediction Input Mars, expect a correct answer. A specific input and expected result can be repeated by anyone. ────────────────────────────────────── 38. Pocket Quiz Capstone · Get One Round Working Make one complete round before extending the quiz to several questions. Lesson files · lessons/foundations-capstone/build-a-round Before you start - Define a function that takes arguments and returns a value. - Use strip() and lower() to clean a reply. - Use if to choose an output from a comparison. By the end - Use a function to compare a cleaned reply with a supplied key. - Use the returned True or False to score one reply. - Test one correct reply and one reply that should score zero. Where you can use it Build one question for a spelling game. Test the reply checker before adding more questions. Test one answer before you build the full quiz. In is_correct(reply, expected), clean the reply and compare it with a tidied, lowercase answer key. The comparison returns True or False. Use an if in the code that calls the function to display a point for a match. Try the same answer with extra spaces and a capital letter. When the function works, you can reuse it with every question in the full quiz. Predict Why pass expected as a parameter? - It forces every answer to be mars. - The same comparison can serve different questions. Worked example (example.py) def is_correct(reply, expected): return reply.strip().lower() == expected print(is_correct(" MARS ", "mars")) Example result True Read an answer, compare it to mars using is_correct, and print 1 for correct and 0 for wrong. Starter program (starter.py) def is_correct(reply, expected): return reply.strip().lower() == expected print(is_correct(" MARS ", "mars")) Hint Use if is_correct(input(), "mars") to choose 1 or 0. Case 1. Try the sample Input Mars Expected output 1 Case 2. Wrong answer Input venus Expected output 0 Case 3. Blank answer Input Expected output 0 Stretch Test is_correct with a second answer key. Reflect What did you learn by building one round before building all three? Check your prediction The same comparison can serve different questions. A parameter lets each call supply a different answer key. ────────────────────────────────────── 39. Pocket Quiz Capstone · Score a Complete Round Add the result from each question and verify a partly correct round. Lesson files · lessons/foundations-capstone/test-full-round Before you start - Use a running total across a loop. - Use a for loop to visit the items in a list. - Check a reply after trimming and lowercasing it. By the end - Use one counter to collect points across the entire quiz. - Use the length of the answer list to show the maximum score. - Test a run with both correct and wrong answers. Where you can use it Give a practice quiz one score for the whole round. Try a run with some correct replies so you can check that the score adds up. Loop through the answer keys in order. Each time, read a fresh reply and use the same cleaning rule as is_correct. Start the score at 0 before the loop and add one when a reply matches. Predict the score for one correct and one wrong reply. A mixed run checks that your program can both award a point and leave the score alone. After the loop, len(answers) gives the number of possible points. Predict Why keep score outside the loop? - It must remember points from all questions. - It must restart on each question. Worked example (example.py) answers = ["mars", "4"] score = 0 for expected in answers: if input().strip().lower() == expected: score += 1 print(f"Score: {score}/{len(answers)}") Example input mars 5 Example result Score: 1/2 Add cow as the third answer key. Print the final score in the same format. Predict the score for a mix of correct and wrong replies, then run it. Starter program (starter.py) answers = ["mars", "4"] score = 0 for expected in answers: if input().strip().lower() == expected: score += 1 print(f"Score: {score}/{len(answers)}") Starter input mars 5 Hint Add cow to the list. The same loop and denominator should handle the extra round. Case 1. Try the sample Input Mars 5 Cow Expected output Score: 2/3 Case 2. All wrong Input venus 7 koala Expected output Score: 0/3 Stretch Write a prediction for all three correct answers, then test it. Reflect What does the mix of correct and wrong answers tell you about your program? Check your prediction It must remember points from all questions. The total should carry over to the next question. ────────────────────────────────────── 40. Pocket Quiz Capstone · Build and Share Pocket Quiz Deliver a three-question quiz with a score, input handling and explained test evidence. Lesson files · lessons/foundations-capstone/pocket-quiz Before you start - Loop over a list of dictionary records. - Use a function to check one reply against an answer key. - Keep a score across a loop and print it after the loop. By the end - Use a record to keep each prompt together with its answer key. - Use the same matching function for each question. - Test that a blank reply still lets the next question run. Where you can use it Make a revision quiz for a classmate. Keep the prompts with their answer keys and test a blank reply before sharing the quiz. Keep each prompt and its lowercase answer key in the same dictionary. Loop over the list of question records and print one prompt at a time. Read one line after each prompt, even when that line is blank. Reuse is_correct from the earlier activity to check the reply against that record's answer. A play_round function can return the final score after printing prompts and scoring each reply. Build the score label from the score and the number of questions. Predict Where should you edit a question and its answer together? - Inside the score counter. - In its dictionary record. Worked example (example.py) question = {"prompt": "Name the red planet.", "answer": "mars"} print(question["prompt"]) Example result Name the red planet. Use the three starter records. Print each prompt, read one answer, and use the same helper function to check each cleaned reply. Award one point per match. Treat blank answers as wrong and continue to the next question. Print Score: points/3 on the final line, using the points earned. Record the input and result from a normal test and a blank-answer test. In your reflection, explain one decision you made. Starter program (starter.py) questions = [ {"prompt": "Name the red planet.", "answer": "mars"}, {"prompt": "What is 2 + 2?", "answer": "4"}, {"prompt": "Which animal says moo?", "answer": "cow"}, ] for question in questions: print(question["prompt"]) input() print("Score: 0/3") Starter input Mars 4 cow Hint Pass the record’s answer to is_correct and add to a shared score on each match. Case 1. Try the sample Input Mars 4 COW Expected output Name the red planet. What is 2 + 2? Which animal says moo? Score: 3/3 Case 2. Blank answer in the middle Input mars cow Expected output Name the red planet. What is 2 + 2? Which animal says moo? Score: 2/3 Case 3. No correct answers Input venus 7 cat Expected output Name the red planet. What is 2 + 2? Which animal says moo? Score: 0/3 Project checklist Run the sample case. Project checklist Try one different case and explain what happened. Marking criterion Program behaviour (4 points) Each required behaviour works on the supplied cases. Marking criterion Use of the lesson concept (3 points) The code uses the main idea in a clear, purposeful way. Marking criterion Test evidence (2 points) The reflection describes a case, its expected result and what happened. Marking criterion Explanation (1 points) The learner explains a change or design decision in their own words. Stretch Use your own three-question topic and ask someone to play. Keep a before-and-after list of improvements. Reflect Explain what is_correct returns and what would happen in a round with one blank answer. Check your prediction In its dictionary record. A record groups the two fields for the same question. ────────────────────────────────────── 41. Build Your Own Python Program · Turn a Request into Test Cases Turn someone’s request into inputs, a decision rule and expected outputs. Lesson files · lessons/build-your-own-program/write-testable-examples Before you start - Read two numbers with input() and int(). - Use an if condition to compare numbers. By the end - Write one input and expected result for each side of a decision. - Run a case at the exact limit and explain why it gives that result. Where you can use it Agree on what a booking, supply or scoring tool should do before you start writing it. Ask what information a person can give you and what answer will help them. A club can tell you how many places are free and how many they need. Your rule is precise when you can say what happens for fewer, exactly enough and too many places. Write a tiny table on paper with input, expected result and actual result. Fill in the expected column first. Compare against it after running the program. A boundary case is a value right at the point where the decision changes. Predict What happens when four pencils are needed and exactly four are available? - The result is True. - The result is False. Worked example (example.py) def enough_pencils(needed, available): return available >= needed print(enough_pencils(4, 4)) print(enough_pencils(5, 4)) Example result True False Build a two-line seat check. Read seats available and seats requested, in that order. Print Booked when there are enough seats. Print Waiting list when the group needs more seats than are available. Starter program (starter.py) available = int(input()) requested = int(input()) print("Waiting list") Starter input 4 4 Hint Write out the results for four available seats and requests for three, four and five seats. Case 1. Try the sample Input 4 4 Expected output Booked Case 2. Seats left over Input 6 3 Expected output Booked Case 3. One seat short Input 4 5 Expected output Waiting list Stretch Try one free seat and one person. Invent another short test for a full event. Reflect What result would change if the rule said there must be a spare seat? Check your prediction The result is True. The greater-than-or-equal comparison includes equality. ────────────────────────────────────── 42. Build Your Own Python Program · Collect Inputs Until the User Is Done Read a list of values that can vary in length and stop cleanly. Lesson files · lessons/build-your-own-program/keep-and-count-input Before you start - Repeat steps with a while loop and exit with break. - Store values in a list with append(). - Clean text with strip() and lower(). By the end - Loop over input until a user types the agreed stop word. - Skip empty entries and keep the useful ones for the final result. Where you can use it Let someone enter club names, item labels or measurements without knowing the number of lines in advance. Use a stop word when the number of entries can change. Read a line, take off surrounding spaces, and check the stop word before saving it. lower() lets the user type different capitals for the stop word. Keep the original cleaned name if you want to show it later. An empty line has its own meaning. Decide to ignore it and go around the loop again. Append each useful item once, and print the count after the loop has stopped. Test a run where the first entry is the stop word. Predict Why does the example finish when the input is CLOSE? - The input function changes capitals into lowercase. - It compares the lowercase form with close. Worked example (example.py) while True: answer = input().strip() if answer.lower() == "close": break print(f"Note: {answer}") print("Notebook closed") Example input Put out chairs CLOSE Example result Note: Put out chairs Notebook closed Read club names until the user enters done. Ignore empty or space-only lines, and recognise done in any mix of capitals. Print Clubs counted: followed by the number entered. Count repeated names as separate entries. Starter program (starter.py) names = [] while True: name = input().strip() if name.lower() == "done": break names.append(name) print(f"Clubs counted: {len(names)}") Starter input Chess Robotics DONE Hint Keep the list outside the loop. Check for the stop word first and only append a name when the cleaned line has text. Case 1. Try the sample Input Chess Robotics DONE Expected output Clubs counted: 2 Case 2. Stop immediately Input done Expected output Clubs counted: 0 Case 3. Same name twice Input Chess Chess Done Expected output Clubs counted: 2 Stretch Print the first name after the count when the list has at least one item. Reflect What happens if you check for the stop word after storing the line? Check your prediction It compares the lowercase form with close. lower() produces the lowercase text used in the condition. ────────────────────────────────────── 43. Build Your Own Python Program · Repair a Rule and Retest It Find a decision error by testing a function on either side of its limit. Lesson files · lessons/build-your-own-program/repair-and-retest Before you start - Write a function with parameters and a return value. - Use assert to check a prediction about code. - Compare whole numbers with < and <=. By the end - Use an exact-limit test to find a comparison bug. - Fix the comparison and show that cases on both sides still pass. Where you can use it Repair a stock alert or eligibility rule and keep its successful cases working. Run the smallest test that shows the problem. If a battery warning should turn on only below 20 percent, try 19, 20 and 21. The value 20 tells you whether the comparison includes the boundary. Keep the comparison in its own function. You can call it with made-up numbers and test one precise result without starting the whole program. After the fix, rerun the original failing test and the two nearby checks. Predict Which input best distinguishes < 20 from <= 20? - 20 - 19 Worked example (example.py) def low_battery(charge, warning_level): return charge < warning_level assert low_battery(19, 20) is True assert low_battery(20, 20) is False print("Battery checks passed") Example result Battery checks passed Repair the supply alert from the starter. A shelf is Ready when the number of items is at or above its target. Read the number of items, then the target. Print Ready or Restock. Use an assertion for a shelf that has exactly enough items. Starter program (starter.py) def needs_more(items, target): return items <= target items = int(input()) target = int(input()) if needs_more(items, target): print("Restock") else: print("Ready") Starter input 8 8 Hint Reproduce the failure with eight items and a target of eight. Find the comparison in needs_more(). Case 1. Try the sample Input 8 8 Expected output Ready Case 2. One item short Input 7 8 Expected output Restock Case 3. Above the target Input 9 8 Expected output Ready Stretch Show the test that would catch an accidental change from < to >. Reflect Explain which single case showed the original error and why. Check your prediction 20 Both comparisons accept 19. They make different decisions about 20. ────────────────────────────────────── 44. Build Your Own Python Program · Build a Score Check Tool Write a small input-and-report tool from an empty Python file and explain your tests. Lesson files · lessons/build-your-own-program/score-check-tool Before you start - Use input(), int(), strip(), and try/except ValueError to read and validate entries. - Store values in a list and loop over them to calculate a result. - Write and test a function with parameters and a return value. By the end - Write a complete program from an empty file with input, a calculation function and a report. - Run the supplied cases and a new input you chose, including an exact-target score. - Show how to run the tool and explain one design choice and one change you made. Where you can use it Help a coach, club organiser or volunteer count how many entries meet a chosen target. Choose who needs the tool and what the number will help them decide. You might count quiz results that reach a target, jump lengths that reach a mark, or packed kits that reach a minimum. Keep the program’s report format the same so the shared cases work. Sketch the input, calculation and report in your own words. Start with the smallest version you can test. Use a short list and your counting function first. Then connect the input loop, handle blank or invalid lines, and print the report. Predict the result for a different set of values before running it. Choose one useful improvement and show it with your own case after the main version works. Predict Why start with a small list when planning your calculation? - Programs with longer lists cannot be tested. - A list with a known result makes the function easier to test on its own. Worked example (example.py) def total_labels(labels): return len(labels) print(total_labels(["Blue", "Green", "Blue"])) Example result 3 Start with a blank editor. Read the target as an integer on the first line. Then read one score per line until done, with spaces and capital letters allowed in the stop word. Ignore blank lines. Count other invalid entries separately. Use a function to count scores at or above the target. Report how many scores were counted, how many met the target and how many entries were invalid. Match the labels shown in Check. Create an empty file for this project. The included starter.py is empty. Starter input 10 8 10 12 done Hint Begin by testing the function on two numbers on either side of the target and one exactly on it. Add the input loop after the function works. Case 1. Try the sample Input 10 8 10 12 done Expected output Scores counted: 3 At or above 10: 2 Invalid entries: 0 Case 2. No valid scores Input 7 unknown done Expected output Scores counted: 0 At or above 7: 0 Invalid entries: 1 Case 3. Negative target and spaces Input -1 -2 -1 bad 0 DONE Expected output Scores counted: 3 At or above -1: 2 Invalid entries: 1 Project requirement Start in an empty editor and write the program from the brief. Project requirement Use a function to count scores at or above the target. A score exactly on the target counts. Project requirement Ignore blank lines, count invalid entries and stop before treating done as a score. Project requirement Show a new input, its predicted result and the actual result. Save your working program. Project requirement Explain how to run your program and show a small improvement in a separate copy. Project checklist I wrote my program from the blank editor and saved it. Project checklist I tested an exact-target score, a blank line and a bad entry. Project checklist I wrote down the input and result of a test I chose myself. Project checklist I can explain my input loop and show a small change. Marking criterion Working program (4 points) The learner demonstrates the correct report for supplied cases and a new input, including equality at the target. Marking criterion Independent use of Python (3 points) The learner explains the input loop and calculation function in their own words and can make a small change from the brief. Marking criterion Testing and repair (2 points) The learner predicts and verifies a new case and can explain a fix or one error condition. Marking criterion Using the tool (1 points) The learner names a real use and tells someone what to enter and how to read the result. Stretch Make a separate copy and add a feature for your chosen user, such as showing how many scores are below the target. Keep your original version available for the shared cases. The ZIP includes added practice files for this lesson. Open its lesson folder and read the included instructions. Reflect Describe the person who could use your tool. Explain one step in your code, then write an input and expected result for the next change you would make. Check your prediction A list with a known result makes the function easier to test on its own. With a known example you can see whether the calculation works before adding the input loop. Install Python packages for a local project Foundations and the core Intermediate exercises use the Python standard library. Follow this guide when you reach the optional Club File Pack lab or start a local project that names extra packages. Choose the right tool 1. Some modules come with Python. Code can import math, csv, pathlib, json, unittest and pdb as soon as Python is installed. 2. A third-party package is code maintained outside Python. PyPI is the Python Package Index, where you can look up package names, supported Python versions and documentation. Open a project’s own documentation when deciding what to install. Browse PyPI · https://pypi.org/ 3. venv comes with Python. It creates a separate environment for one project and normally includes pip, which installs libraries. Run python -m pip so the same Python sees the packages when it runs your code. 4. pipx installs standalone Python command-line applications in their own environments. uv is an optional tool that can also manage Python versions, project environments and dependencies. The course uses venv plus pip for its local package lab. Read the official Python packaging guide · https://packaging.python.org/en/latest/tutorials/installing-packages/ 1. Find the supplied requirements 1. Download and extract the Intermediate Python workbook. Inside it, open the lesson folder below. It contains README.txt, requirements.txt and the scripts for the Club File Pack. lessons/documents-and-images/build-a-club-file-pack 2. Open a terminal in this lesson folder. Use Command Prompt on Windows or Terminal on Mac. List the files with dir on Windows or ls on Mac to check your location. What you should see · requirements.txt, check_packages.py, make_fixtures.py, club_pack.py and verify_pack.py are visible. 3. Open requirements.txt in VS Code. Each line gives a package name and a version. Use Python 3.11 or newer for this lab. Check the selected Python version with py --version on Windows or python3 --version on Mac. 2. Create and activate a virtual environment 1. Windows. Run these two lines in Command Prompt from the folder that contains requirements.txt. Use python in place of py on the first line if that was your working installation command. py -m venv .venv .venv\Scripts\activate.bat 2. Mac. Run these two lines in Terminal from the same folder. python3 -m venv .venv source .venv/bin/activate 3. Look for (.venv) near the start of your terminal prompt. Confirm which pip your Python will use. python -m pip --version What you should see · A pip version and a path that contains .venv. 3. Install and check the packages 1. With the environment active, run this command while connected to the internet. -r tells pip to read requirements.txt. This lab uses prebuilt packages called wheels. python -m pip install --only-binary=:all: -r requirements.txt 2. Check that the installed packages agree with each other and that the lab can import them. python -m pip check python check_packages.py What you should see · No broken requirements found. Then The four document packages are ready. 3. The packages are openpyxl for spreadsheets, pypdf for PDF pages, Pillow for images, and ReportLab for making sample PDFs. Pillow is a package name. Its Python imports start with PIL. 4. In VS Code, open the lab folder and choose Python: Select Interpreter. Select the .venv entry. For a later terminal session, activate the environment again from this folder. Type deactivate when you finish. 4. Run the lab 1. Generate the fictional input files, make the report pack, then verify it. Run each line with the environment active. python make_fixtures.py python club_pack.py python verify_pack.py What you should see · A pack folder with spreadsheet, PDF and image output. The verification script prints Verified the workbook, three PDF pages and two PNG copies. 2. The verification script reads the files for you. To inspect them yourself, open PDF and PNG files in a browser. Open XLSX files in a spreadsheet app such as the free LibreOffice Calc. Open an XLSX file in LibreOffice · https://help.libreoffice.org/latest/en-US/text/shared/guide/ms_user.html Prepare a copy for a classroom without internet 1. On a connected computer with the same operating system, CPU architecture and Python major and minor version as the classroom computer, open the lab folder and activate its environment. Download the wheels while connected. python -m pip download --only-binary=:all: -r requirements.txt -d wheels What you should see · A wheels folder with the libraries and the packages they depend on. 2. Copy the workbook and the wheels folder to the classroom computer. Place wheels beside requirements.txt in the lab folder. Create and activate a fresh .venv there using the steps above. Install from the copied files. python -m pip install --no-index --find-links=wheels -r requirements.txt 3. Repeat the package check and run the lab scripts. Prepare a separate wheel folder for each different operating system, CPU architecture or Python minor version used in class. 4. Teacher option. If the classroom uses 64-bit Windows on Intel or AMD with CPython 3.15, this command can prepare those wheels from a connected Mac. Put the resulting folder beside requirements.txt on Windows and name it wheels. Use the matching-system instructions above for other targets. python -m pip download --platform win_amd64 --implementation cp --python-version 3.15 --abi cp315 --only-binary=:all: -r requirements.txt -d windows-wheels If an install or import fails 1. If Python says ModuleNotFoundError, compare the interpreter in your terminal with the one selected in VS Code, then check which environment holds the package. python -c "import sys; print(sys.executable)" python -m pip show Pillow 2. If the active .venv says No module named pip, bootstrap pip in that environment and repeat the version check. python -m ensurepip --upgrade python -m pip --version 3. If pip says requirements.txt could not be opened, return to the lab folder and list the files. If you see an externally managed environment message, activate the project’s .venv and run the install again. 4. If pip reports that a wheel is unavailable, check the supported Python versions and files on the package’s PyPI page. For a copied wheel folder, check the classroom computer’s OS, CPU architecture and Python version against the computer that prepared it. See Pillow’s supported versions and wheels · https://pypi.org/project/Pillow/ 5. Coding Studio runs the standard-library activities. Run the Club File Pack scripts in a local terminal or VS Code using the lab’s .venv. Install Git when a lesson uses project history 1. Open Command Prompt on Windows or Terminal on Mac and check whether Git is already installed. git --version What you should see · A line starting with git version. 2. Windows. If Git is missing, download Git for Windows. Open the installer and keep the option that makes Git available from the command line. Close and reopen Command Prompt, then repeat git --version. Get Git for Windows · https://git-scm.com/install/windows 3. Mac. If Git is missing, install the Apple Command Line Tools. Follow the system installer, then reopen Terminal and repeat git --version. Git setup options for Mac · https://git-scm.com/install/mac xcode-select --install 4. Git saves project versions on your computer. GitHub is a separate website for sharing repositories. Start with the local commands in your lesson. Run the other local labs 1. The workshop HTTP lab uses two terminals and Python’s built-in http.server. Follow web-lab/README.txt. The exercise serves fictional files on your own computer and includes a saved response. 2. The Radio Shift Diagnostics lab uses Python’s built-in pdb debugger. Its README.txt gives the exact commands to type at the (Pdb) prompt. 3. The Stock Report lab uses Git and the built-in unittest module. Use the Git version check above, then follow the README in the lab folder. The normal files, reports, and capstones use Python’s standard library.