| Hello, World! | 2 Sep 2026 | 7 Sep 2026 | 5 | click to copy A classic first program to test that your toolchain (runtime environment, compiler, IDE, etc.) is set up properly is the โHello, World!โ program.
โฆthe tradition of using the phrase โHello, World!โ as a test message was influenced by an example program in the 1978 book The C Programming Languageโฆ
See Wikipedia page to read more about it.
Before starting, complete the software install instructions.
1. Create a Project
Create a folder for your class projects (for example, Documents/HCC-Computer-Science). Open it in VS Code by navigating to File > Open Folder.
In the Explorer panel (two pages icon on the left), create a new file named main.py.
2. Print โHello, World!โ
Type the following code into main.py:
print("Hello, World!")
Run your program using the โRun Python Fileโ button (play icon, top right). You can also open the integrated terminal (View > Terminal) and run:
python main.py
You should see Hello, World! printed in the terminal.
The term โprintingโ in computer programming originates from the early days of computing, when output was often produced on physical printers. In the 1950s and 1960s, computers used line printers, which printed output on paper, line by line. Programmers would write code to โprintโ output to the printer, which would then produce a physical printout of the results.
3. Turn it In
Upload your main.py file to the โHello, World!โ assignment in ThinkWave. Congratulations, youโve just completed your first programming project! ๐ |
| Fix the Variables | 8 Sep 2026 | 14 Sep 2026 | 2 | click to copy In this assignment you will fix a broken Python program.
The program is supposed to ask the user for the current temperature, calculate the difference between the current temperature and the freezing point of water, and print the result.
However, the program is unfinished. Your job is to add code where the TODO comments are so that the program works as expected.
Paste the following code into a new Python project:
# TODO: Define the units of temperature (e.g. "Fahrenheit")
# Ask the user for the current temperature
temperature = input("Enter the current temperature in " + units + ": ")
# Convert the temperature to a float
numeric_temperature = float(temperature)
# TODO: Define the freezing point of water
# Calculate the difference between the current temperature and the freezing point of water
difference = numeric_temperature - freezing_point
# Print the result
print("The current temperature is: " + str(numeric_temperature) + " degrees " + units)
print("The freezing point of water is: " + str(freezing_point) + " degrees " + units)
print("The difference between the current temperature and the freezing point of water is: " + str(difference) + " degrees " + units)
When youโve finished, upload the .py file to ThinkWave. |
| Mad Libs | 18 Sep 2026 | 24 Sep 2026 | 5 | click to copy Based on the first on the first exercise in the input/output video from Bro Code, I want you to extend the Mad Libs project to include a full story.
Your program must meet the following specifications:
- Ask the user for at least three nouns
- Ask the user for at least two adjectives
- Ask the user for at least one verb
- Print a story using the userโs input (at least 50 words)
When youโre happy with your Mad Libs game, upload the .py file to ThinkWave. |
| Make a Quiz | 25 Sep 2026 | 1 Oct 2026 | 9 | click to copy Make a quiz about something youโre passionate about! Sports, music, gamesโฆ the sky is the limit. Your quiz should follow these specifications:
- Print quiz instructions to the user
- Ask the user at least 101 ๐ questions
- Tell the user if they were right or wrong after each question
- Give the user a score at the end
To accomplish this you will need to use if statements to do different things based on user input.
When a user answers a question correctly, you should add 1 to a score variable. When a user answers a question incorrectly, do nothing. At the end of the quiz, you should print the userโs score.
To add 1 to a score variable, you can use the += operator. For example:
score = 0
# If the user answers a question correctly, add 1 to the score like this:
score += 1
Your questions may be multiple choice, true/false, or fill in the blank. Make sure to tell the user the expected format for their answer. For example, if the question is โWhat is the capital of France?โ, the user should answer โParisโ (uppercase) not โparisโ (lowercase).
When youโve finished, have a friend or family member try out the quiz!
When youโre happy with your quiz, upload the .py file to ThinkWave. |
| Simple Calculator | 1 Oct 2026 | 7 Oct 2026 | 8 | click to copy
Write a simple calculator program that can add, subtract, multiply, and divide two numbers. Your program must meet the following specifications:
- Ask the user for two numbers
- Ask the user for an operation (
+, -, *, or /)
- Use
if statements to perform the correct calculation based on the operation
- Print the result in a clear, readable format
For example, if the user enters 10, 3, and +, your program should print something like:
10 + 3 = 13
Remember to convert user input to numbers before doing math. You can use float() to convert a string to a decimal number:
first_number = float( input("Enter the first number: ") )
Example Code
Here is a starting point. Fill in the TODO comments to meet the specifications above!
# Ask the user for two numbers
first_number = float( input("Enter the first number: ") )
second_number = float( input("Enter the second number: ") )
# Ask the user for an operation
operation = input("Enter an operation (+, -, *, /): ")
# Use if statements to perform the correct calculation
# TODO
# Print the result
# TODO
Additional Challenges (not required)
- If the user enters an invalid operation, print an error message instead of a result
- If the user tries to divide by zero, print an error message instead of a result
- Allow the user to perform multiple calculations in a row
When youโre happy with your calculator, upload the .py file to ThinkWave. |
| Theme Park Ride Checker | 8 Oct 2026 | 14 Oct 2026 | 8 | click to copy
Theme parks use rules to decide who can ride each attraction. Some rides require a minimum height and age. Others let shorter guests ride if they are with an adult.
Write a program that asks the user a few questions and tells them which rides they are allowed to ride. Your program must meet the following specifications:
- Ask the user for their age (as a number)
- Ask the user for their height in inches (as a number)
- Ask the user if they are with an adult (
yes or no)
- Check eligibility for all three rides below using
if statements and logical operators (and, or, not)
- Print whether the user can ride each ride
Ride Rules
| Ride | Rule |
|---|
| Mini Coaster | At least 8 years old and at least 42 inches tall | | Big Drop | At least 12 years old and at least 54 inches tall | | River Rapids | At least 48 inches tall or with an adult |
For example, a 10-year-old who is 50 inches tall and not with an adult should be able to ride the Mini Coaster and River Rapids, but not the Big Drop.
Logical Operators
Use and when all conditions must be true:
if age >= 8 and height >= 42:
print("You can ride the Mini Coaster!")
Use or when at least one condition must be true:
if height >= 48 or with_adult == "yes":
print("You can ride River Rapids!")
Example Code
Here is a starting point. Fill in the TODO comments to meet the specifications above!
# Ask the user for their age and height
age = int( input("How old are you? ") )
height = int( input("How tall are you (in inches)? ") )
# Ask the user if they are with an adult
with_adult = input("Are you with an adult? (yes/no): ")
# Check eligibility for each ride
# TODO: Mini Coaster
# TODO: Big Drop
# TODO: River Rapids
Additional Challenges (not required)
- Print a friendly message when the user cannot ride a ride (not just when they can)
- Add a fourth ride with a rule that uses
not
- Ask the user if they want to check another person and run the program again
When youโre happy with your ride checker, upload the .py file to ThinkWave. |
| Tip Calculator | 15 Oct 2026 | 21 Oct 2026 | 8 | click to copy
When you eat at a restaurant, you often need to calculate a tip and split the bill. Instead of doing the math in your head, write a program that does it for you!
Your program must meet the following specifications:
- Define a function called
calculate_tip that takes a bill amount and tip percentage and returns the tip amount
- Define a function called
calculate_total that takes a bill amount and tip amount and returns the total
- Define a function called
split_bill that takes a total and number of people and returns the cost per person
- Ask the user for the bill amount, tip percentage, and number of people
- Call your functions and print the results in a clear format
For example, if the user enters a $40.00 bill, 20 percent tip, and 2 people, your program might print:
Bill: $40.00
Tip (20%): $8.00
Total: $48.00
Each person pays: $24.00
Functions
A function is a reusable block of code. Use the def keyword to define a function, and use return to send a value back to the code that called it:
def add_tax(price, tax_rate):
tax = price * tax_rate
return price + tax
total = add_tax(10, 0.08)
print(total) # 10.8
Example Code
Here is a starting point. Fill in the TODO comments to meet the specifications above!
def calculate_tip(bill, tip_percent):
# TODO: calculate and return the tip amount
pass
def calculate_total(bill, tip):
# TODO: calculate and return the total
pass
def split_bill(total, people):
# TODO: calculate and return the cost per person
pass
# Ask the user for input
bill = float( input("Enter the bill amount: $") )
tip_percent = float( input("Enter the tip percentage: ") )
people = int( input("How many people are splitting the bill? ") )
# Call your functions
# TODO
# Print the results
# TODO
Additional Challenges (not required)
- Round dollar amounts to two decimal places (hint:
round(amount, 2))
- If the user enters
0 people, print an error message instead of dividing
- Allow the user to calculate tips for multiple bills in a row
When youโre happy with your tip calculator, upload the .py file to ThinkWave. |
| High Score Finder | 22 Oct 2026 | 28 Oct 2026 | 10 | click to copy
Video games often track player scores. Given a list of scores, how do you find the best one? The worst one? The average? In this project you will write algorithms โ step-by-step procedures โ to analyze a list of numbers.
Your program must meet the following specifications:
- Create a list with at least 5 scores (you may hardcode them or ask the user to enter them)
- Use a
for loop to look at every score in the list
- Keep track of the highest score seen so far
- Keep track of the lowest score seen so far
- Keep track of the total of all scores (you will use this to calculate the average)
- Print the high score, low score, and average score when the loop is finished
For example, if your list is [85, 92, 78, 95, 88], your program should print something like:
High score: 95
Low score: 78
Average score: 87.6
To calculate the average, divide the total of all scores by how many scores are in the list:
average = total / len(scores)
Lists
A list stores multiple values in order. You can access items by index (starting at 0):
scores = [85, 92, 78, 95, 88]
print(scores[0]) # 85
print(scores[3]) # 95
print(len(scores)) # 5
For Loops
A for loop lets you do something once for each item in a list:
scores = [85, 92, 78]
for score in scores:
print(score)
This prints each score on its own line.
Example Code
Here is a starting point. Fill in the TODO comments to meet the specifications above!
# Create a list of scores
scores = [85, 92, 78, 95, 88]
# Start by assuming the first score is both the highest and lowest
highest = scores[0]
lowest = scores[0]
total = 0
# Loop through every score in the list
for score in scores:
# TODO: if this score is higher than highest, update highest
# TODO: if this score is lower than lowest, update lowest
# TODO: add this score to total
# Calculate the average
# TODO
# Print the results
# TODO
Additional Challenges (not required)
- Print which position the high score is at (1st, 2nd, 3rd, etc.)
When youโre happy with your high score finder, upload the .py file to ThinkWave. |
| Password Strength Checker | 29 Oct 2026 | 4 Nov 2026 | 12 | click to copy
Ever notice how websites tell you if your password is โweak,โ โmedium,โ or โstrongโ? In this project, you will write a program that analyzes passwords and rates their strength based on multiple criteria.
Your program must meet the following specifications:
- Create a function called
check_password_strength that takes a password as input and returns a strength rating
- Check for the following criteria:
- Length: Password must be at least 8 characters long
- Uppercase letters: Password contains at least one uppercase letter (A-Z)
- Lowercase letters: Password contains at least one lowercase letter (a-z)
- Digits: Password contains at least one number (0-9)
- Special characters: Password contains at least one special character (
!@#$%^&*)
- Assign a score based on how many criteria are met:
- 0-1 criteria met: โVery Weakโ
- 2 criteria met: โWeakโ
- 3 criteria met: โMediumโ
- 4 criteria met: โStrongโ
- 5 criteria met: โVery Strongโ
- Ask the user to enter one password
- Print the strength rating
- Print which criteria were met and which were not
For example:
Checking for Character Types
You can check if a string contains uppercase, lowercase, digits, or other characters by looping through each character:
password = "MyPassword123!"
# Check if string contains uppercase
has_upper = False
for char in password:
if char.isupper():
has_upper = True
print(has_upper) # True
The isupper(), islower(), and isdigit() methods check a single character.
Example Code
def check_password_strength(password):
"""Analyze password strength and return a rating."""
# TODO: Check each criterion and count how many are met
# TODO: Determine strength rating based on count
# TODO: Return the rating
password = input("Enter a password: ")
# TODO: Call check_password_strength()
# TODO: Print the rating and which criteria were met/not met |
| Rock, Paper, Scissors Tournament | 5 Nov 2026 | 11 Nov 2026 | 12 | click to copy
Rock, Paper, Scissors is a classic game. But what if you played multiple rounds and kept score? In this project, you will write a program that plays multiple rounds against the computer, keeps track of wins and losses, and crowns a champion!
Your program must meet the following specifications:
- Import the
random module to pick the computerโs move
- Define a function called
get_winner that compares the playerโs move and computerโs move and returns 'player', 'computer', or 'tie'
- Use a
while or for loop to play multiple rounds (at least 3)
- In each round:
- Ask the player to choose rock, paper, or scissors
- Randomly pick a move for the computer
- Call
get_winner to determine the round winner
- Print the result (what each player chose and who won)
- Keep track of player wins, computer wins, and ties
- After all rounds are finished, print a final leaderboard showing total wins for each player
For example, after 3 rounds, your program might print:
=== ROUND 1 ===
You chose: rock
Computer chose: scissors
You win! ๐
=== ROUND 2 ===
You chose: paper
Computer chose: paper
It's a tie!
=== ROUND 3 ===
You chose: scissors
Computer chose: rock
Computer wins!
=== FINAL SCORE ===
You: 1 win
Computer: 1 win
Ties: 1
The Random Module
The random module lets you pick random values. Import it at the top and use random.choice() to pick from a list:
import random
moves = ['rock', 'paper', 'scissors']
computer_move = random.choice(moves)
print(computer_move) # could be any of the three
Game Rules
- Rock beats Scissors
- Scissors beats Paper
- Paper beats Rock
- If both players chose the same move, itโs a tie
Example Code
Here is a starting point. Fill in the TODO comments to meet the specifications above!
import random
def get_winner(player, computer):
"""Compare moves and return the winner."""
# TODO: return 'player', 'computer', or 'tie'
pass
# Game setup
moves = ['rock', 'paper', 'scissors']
player_wins = 0
computer_wins = 0
ties = 0
# Play multiple rounds
# TODO: use a while or for loop to play at least 3 rounds
# Get player input
player_move = input("Choose rock, paper, or scissors: ").lower()
# Get computer move
computer_move = random.choice(moves)
# Determine winner
# TODO: call get_winner() and store the result
# Print round results
# TODO: print what each player chose and who won
# Update scores
# TODO: increment the appropriate counter
# Print final leaderboard
# TODO: print player wins, computer wins, and ties
Additional Challenges (not required)
- Let the player choose how many rounds to play
- Validate player input (reject moves that arenโt rock, paper, or scissors)
- Print a celebratory message if the player wins the tournament
- Ask the player if they want to play again after the tournament ends
- Keep a running record of tournaments played (how many times the player has beaten the computer overall)
When youโre happy with your tournament, upload the .py file to ThinkWave. |
| Simple Shop | 12 Nov 2026 | 18 Nov 2026 | 12 | click to copy In early computer RPGs like Rogue, inventory systems allowed players to collect and manage items during gameplay. In this project, you will write a program where you visit a shop and buy items.
Ever heard of a โRoguelikeโ game? These games get their name from the 1980 game Rogue, which let players explore dungeons, collect items, and manage their inventory. Roguelikes are known for features like permadeath, random item drops, and challenging gameplay, and many modern games are inspired by this classic genre.
Your program must meet the following specifications:
- Start with 100 gold
- Display a list of available items (sword, shield, boots, helmet, etc.)
- Loop until user runs out of gold or types โexitโ
- In each turn:
- Show current gold and ask user to pick an item (or type โexitโ)
- Display the itemโs price
- Ask if the user wants to buy it
- If yes and user has enough gold, add item to inventory and deduct gold
- If no, return to item selection
- When the game ends, print your final inventory and remaining gold
For example:
Welcome to the shop! You have 100 gold.
=== SHOP INVENTORY ===
- sword
- shield
- boots
- helmet
Pick an item (or type 'exit'): sword
Price: 50 gold
Buy this item? (yes/no): yes
You bought the sword!
You now have 50 gold.
Pick an item (or type 'exit'): shield
Price: 30 gold
Buy this item? (yes/no): no
Pick an item (or type 'exit'): boots
Price: 20 gold
Buy this item? (yes/no): yes
You bought the boots!
You now have 30 gold.
Pick an item (or type 'exit'): exit
=== PERSONAL INVENTORY ===
- sword
- boots
Total spent: 70 gold
Gold remaining: 30 gold
Working With Lists
You can find the index of an item in a list by using the index() method.
Example Code
# Item names and their prices
item_names = ["sword", "shield", "boots", "helmet"]
item_prices = [50, 30, 20, 25]
# Player inventory and gold
inventory = []
gold = 100
print("Welcome to the shop! You have 100 gold.")
print(f"Available items: {', '.join(item_names)}")
while True:
print()
choice = input(f"Pick an item (or type 'exit'): ").lower()
if choice == "exit":
break
# TODO: Allow user to buy items if they have gold for it
# TODO: Print final inventory with total spent and remaining gold
Additional Challenges (not required)
- Only let an item be purchased once
When youโre happy with your program, upload the .py file to ThinkWave. |
| Haggle at the Shop | 19 Nov 2026 | 25 Nov 2026 | 12 | click to copy In this project, you will extend the Simple Shop assignment with haggling mechanics. Now you can negotiate prices with the shopkeeper, but the further your offer is from the asking price, the more likely theyโll refuse.
Your program must meet the following specifications:
- Show current gold and ask user to pick an item (or type โexitโ)
- If item not found or already sold, show error and ask again
- Display the itemโs base price
- Ask user to haggle by entering a price
- The shopkeeper randomly decides to accept or refuse based on the haggle distance
- If accepted, add item to inventory and deduct haggled price from gold
- If refused, item remains for sale
- If user doesnโt have enough gold, show error
For example:
Welcome to the shop! You have 100 gold.
=== SHOP INVENTORY ===
- sword
- shield
- boots
- helmet
Pick an item (or type 'exit'): sword
The shopkeeper asks for 50 gold.
Your offer: 40
The shopkeeper considers... and ACCEPTS!
You bought the sword for 40 gold!
You now have 60 gold.
Pick an item (or type 'exit'): shield
The shopkeeper asks for 30 gold.
Your offer: 10
The shopkeeper considers... and REFUSES!
Pick an item (or type 'exit'): boots
The shopkeeper asks for 20 gold.
Your offer: 20
The shopkeeper considers... and ACCEPTS!
You bought the boots for 20 gold!
You now have 40 gold.
Pick an item (or type 'exit'): exit
=== PERSONAL INVENTORY ===
- sword
- boots
Total spent: 60 gold
Gold remaining: 40 gold
Haggling Logic
The shopkeeperโs acceptance is based on how far your offer is from the base price.
For example, if the item costs 50 gold and your offer is 48, the shopkeeper has a 90% chance of accepting.
However, if the item costs 50 gold and your offer is 35, the shopkeeper only has a 40% chance of accepting.
The shopkeeperโs acceptance logic is already implemented using random.randint() to generate a random number and compare it to the acceptance chance.
Error Handling
When asking the user for their offer, itโs important to make sure they actually type a number! If the user enters something thatโs not a number (like "twenty"), the program should show an error message and ask again.
You can do this using a while True loop and a try...except block to catch any errors:
while True:
offer_input = input("Your offer: ")
try:
haggle_price = int(offer_input)
break # It's a number, exit the loop!
except ValueError:
print("Please enter a valid number for your offer.")
This way, your program wonโt crash, and will keep asking until the user enters a valid number!
Example Code
import random
# Item names and their prices
item_names = ["sword", "shield", "boots", "helmet"]
item_prices = [50, 30, 20, 25]
# Player inventory and gold
inventory = []
gold = 100
print("Welcome to the shop! You have 100 gold.")
print(f"Available items: {', '.join(item_names)}")
def shopkeeper_accepts(haggle_price, base_price):
"""Decides if the shopkeeper accepts the haggled price."""
difference = abs(haggle_price - base_price)
if difference == 0:
accept_chance = 100
elif difference <= 5:
accept_chance = 90
elif difference <= 10:
accept_chance = 70
elif difference <= 15:
accept_chance = 40
else:
accept_chance = 10
return random.randint(1, 100) <= accept_chance
while True:
print()
choice = input(f"Pick an item (or type 'exit'): ").lower()
if choice == "exit":
break
# Get the item's base price
item_index = item_names.index(choice)
base_price = item_prices[item_index]
print(f"The shopkeeper asks for {base_price} gold.")
# TODO: Get haggle price from user
# Use function for shopkeeper decision
if shopkeeper_accepts(haggle_price, base_price):
print("The shopkeeper considers... and ACCEPTS!")
# TODO: Complete transaction
print(f"You bought the {choice} for {haggle_price} gold!")
print(f"You now have {gold} gold.")
else:
print("The shopkeeper considers... and REFUSES!")
# TODO: Print final inventory with prices, total spent, and remaining gold
Additional Challenges (not required)
- Only let an item be purchased once
- Let the user try haggling for multiple items in one session
- Display how much gold the user saved by haggling if they paid less than the base price
When youโre happy with your program, upload the .py file to ThinkWave. |
| Cat and Dog Facts | 26 Nov 2026 | 2 Dec 2026 | 6 | click to copy In this project, you will write a program that fetches random cat and dog facts from the internet using APIs.
Your program must meet the following specifications:
- Display a menu with options: get a cat fact, get a dog fact, or quit
- When the user picks a fact type, send a request to the matching API and print the fact
- Loop back to the menu after showing a fact
- Handle the case where the request fails (for example, no internet connection) without crashing
For example:
=== Fact Menu ===
1. Cat fact
2. Dog fact
3. Quit
Choice: 1
Fetching a cat fact...
Cats have five toes on their front paws, but only four toes on their back paws.
Choice: 2
Fetching a dog fact...
The average dog can run at speeds of up to 19mph.
Choice: 3
Goodbye!
Working with APIs
This project uses the requests library, which is not part of Pythonโs standard library. Install it first:
pip install requests
You can send a request to a URL and get the response back as a dictionary using .json():
import requests
response = requests.get("https://catfact.ninja/fact")
data = response.json()
print(data["fact"])
Some APIs return more deeply nested data. The dog facts API returns a list of facts under "data", where each factโs text is under "attributes":
import requests
response = requests.get("https://dogapi.dog/api/v2/facts")
data = response.json()
print(data["data"][0]["attributes"]["body"])
Example Code
import requests
def get_cat_fact():
# TODO: send a request to https://catfact.ninja/fact and print the fact
pass
def get_dog_fact():
# TODO: send a request to https://dogapi.dog/api/v2/facts and print the fact
pass
while True:
print("\n=== Fact Menu ===")
print("1. Cat fact")
print("2. Dog fact")
print("3. Quit")
choice = input("\nChoice: ")
if choice == "1":
get_cat_fact()
elif choice == "2":
get_dog_fact()
elif choice == "3":
print("Goodbye!")
break
else:
print("Invalid choice. Try again.")
When youโre happy with your program, upload the .py file to ThinkWave. |
| Contact Book (Part 1) | 3 Dec 2026 | 9 Dec 2026 | 12 | click to copy A contact book is a simple database where you store information about people. In this project, you will write a program that manages contacts using a dictionary data structure.
Your program must meet the following specifications:
- Create a contacts dictionary where each contact has a name (key) and information (value)
- Each contactโs information should include: phone number, email, and address
- Display a menu with options: add contact, view all contacts, search for a contact, delete a contact, or quit
- Implement each menu option as a function
For example:
Contact Book Menu
1. Add contact
2. View all contacts
3. Search for contact
4. Delete contact
5. Quit
Choice: 1
Enter name: Alice
Enter phone: 555-1234
Enter email: [email protected]
Enter address: 123 Main St
Contact saved!
Choice: 2
=== All Contacts ===
Alice - Phone: 555-1234, Email: [email protected], Address: 123 Main St
Choice: 3
Enter name to search: Alice
Found: Alice
Phone: 555-1234
Email: [email protected]
Address: 123 Main St
Choice: 5
Goodbye!
Working with Dictionaries
You can create a dictionary and add key-value pairs:
contacts = {}
contacts["Alice"] = {"phone": "555-1234", "email": "[email protected]", "address": "123 Main St"}
You can access values by key:
print(contacts["Alice"]["phone"]) # 555-1234
You can check if a key exists:
if "Alice" in contacts:
print("Contact found")
You can loop through a dictionary:
for name in contacts:
info = contacts[name]
print(f"{name}: {info['phone']}")
You can delete a key-value pair:
del contacts["Alice"]
Example Code
def add_contact(contacts):
# TODO: Get name and details, add to dictionary, print confirmation
pass
def view_all_contacts(contacts):
# TODO: Loop through contacts and print each one, handle empty book
pass
def search_contact(contacts):
# TODO: Search by name, print info if found or error if not
pass
def delete_contact(contacts):
# TODO: Delete by name, print confirmation or error
pass
# Main program
contacts = {}
while True:
print("\n=== Contact Book Menu ===")
print("1. Add contact")
print("2. View all contacts")
print("3. Search for contact")
print("4. Delete contact")
print("5. Quit")
choice = input("\nChoice: ")
if choice == "1":
add_contact(contacts)
elif choice == "2":
view_all_contacts(contacts)
elif choice == "3":
search_contact(contacts)
elif choice == "4":
delete_contact(contacts)
elif choice == "5":
print("Goodbye!")
break
else:
print("Invalid choice. Try again.") |
| Contact Book (Part 2) | 10 Dec 2026 | 16 Dec 2026 | 9 | click to copy In this project, you will extend Contact Book (Part 1) to save and load contacts from a file. Your contact data will now persist between program runs.
Your program must meet the following specifications:
- Start by loading contacts from a file (if it exists)
- Keep all functionality from Part 1: add, view, search, delete contacts
- When user quits, save all contacts to a file
- Handle errors gracefully (missing file, corrupted data)
- Use JSON format to store contacts
For example:
=== Contact Book ===
Loaded 2 contacts from file.
Contact Book Menu
1. Add contact
2. View all contacts
3. Search for contact
4. Delete contact
5. Quit
Choice: 1
Enter name: Bob
Enter phone: 555-5678
Enter email: [email protected]
Enter address: 456 Oak St
Contact saved!
Choice: 5
Saving contacts to file...
Goodbye!
The contacts.json file would contain:
{
"Alice": {"phone": "555-1234", "email": "[email protected]", "address": "123 Main St"},
"Bob": {"phone": "555-5678", "email": "[email protected]", "address": "456 Oak St"}
}
Working with Files and JSON
You can read a JSON file:
import json
with open("contacts.json", "r") as file:
contacts = json.load(file)
You can write a JSON file:
import json
with open("contacts.json", "w") as file:
json.dump(contacts, file)
You can handle file errors:
import json
try:
with open("contacts.json", "r") as file:
contacts = json.load(file)
except FileNotFoundError:
print("No saved contacts found. Starting fresh.")
contacts = {}
Example Code
import json
def load_contacts():
# TODO: Try to load contacts from "contacts.json"
# TODO: If file doesn't exist, return empty dictionary
# TODO: If file is corrupted, return empty dictionary and show error
pass
def save_contacts(contacts):
# TODO: Save contacts to "contacts.json" in JSON format
# TODO: Show confirmation message
pass
def add_contact(contacts):
# TODO: Get name and details, add to dictionary, print confirmation
pass
def view_all_contacts(contacts):
# TODO: Loop through contacts and print each one, handle empty book
pass
def search_contact(contacts):
# TODO: Search by name, print info if found or error if not
pass
def delete_contact(contacts):
# TODO: Delete by name, print confirmation or error
pass
# Main program
contacts = load_contacts()
while True:
print("\n=== Contact Book Menu ===")
print("1. Add contact")
print("2. View all contacts")
print("3. Search for contact")
print("4. Delete contact")
print("5. Quit")
choice = input("\nChoice: ")
if choice == "1":
add_contact(contacts)
elif choice == "2":
view_all_contacts(contacts)
elif choice == "3":
search_contact(contacts)
elif choice == "4":
delete_contact(contacts)
elif choice == "5":
save_contacts(contacts)
print("Goodbye!")
break
else:
print("Invalid choice. Try again.") |
| Choose Your Own Adventure | 17 Dec 2026 | 30 Dec 2026 | 15 | click to copy A Choose Your Own Adventure (CYOA) story lets the reader make choices that change what happens next. In this project, you will write a program that runs a story of your own design. Pick any topic you like.
Your program must meet the following specifications:
- Store your story in a dictionary where each key is a page number and each value is a dictionary with:
text: the text shown to the reader on this page
options: a list of dictionaries, each with:
text: the text of the choice shown to the reader
page: the page number to go to next, or None if this choice ends the story
- Write a function that prints a single pageโs text and options
- Use a loop to:
- Show the current page
- Ask the reader to pick an option
- If the choice is valid, move to that page
- If the choice is invalid, print a message and show the same page again
- Your story must have at least 8 pages
Additional Challenges (optional)
- Inventory system: give the reader an inventory (a list). Some pages let them pick up an item (for example, a key). Add a page where the reader can only choose a certain option if they have a specific item in their inventory (for example, they need the key to escape).
- Saving and loading: save the readerโs progress to a file using the json module. When the program starts, check if a save file exists and let the reader continue from where they left off.
Example Story
Here is a short example with 2 pages (yours must have at least 8):
story = {
1: {
"text": "You wake up and hear a knock at the door.",
"options": [
{"text": "Open the door", "page": 2},
{"text": "Ignore it", "page": 2}
]
},
2: {
"text": "The knocking stops. THE END",
"options": [
{"text": "Quit", "page": None}
]
}
}
Example Code
def show_page(page):
# TODO: print page["text"], then print each option with a number, e.g. "1) Open the door"
pass
story = {
# fill in your story here
}
current_page = 1
while current_page is not None:
page = story[current_page]
show_page(page)
choice = input("\n>> ")
# TODO: check if choice is a valid option number; if valid, set current_page to that
# option's "page", otherwise print a warning and show the same page again
Example Output
You wake up and hear a knock at the door.
1) Open the door
2) Ignore it
>> 3
Invalid choice "3"
You wake up and hear a knock at the door.
1) Open the door
2) Ignore it
>> 2
The knocking stops. THE END
1) Quit
>> 1 |
| Portfolio | 13 Jan 2027 | 19 Jan 2027 | 18 | click to copy Congratulations on completing the class! Now itโs time to compile your work into a portfolio.
Your portfolio should include all tests and projects you completed this semester.
Organize the projects chronologically, and make sure to include the name of each assignment.
When youโve finished, submit your portfolio to ThinkWave. |
| Total | | | 163 | |