๐ Dictionaries ๐ Keys & Values
Part A: Create a dictionary called hero with these keys and values:
Print the entire dictionary.
Part B: Print individual values:
Part C: Update the dictionary:
Example Output:
=== Part A ===
{'name': 'Link', 'hearts': 3, 'rupees': 100, 'weapon': 'sword'}
=== Part B ===
Name: Link
Hearts: 3
Rupees: 100
=== Part C ===
{'name': 'Link', 'hearts': 5, 'rupees': 50, 'weapon': 'master sword'}
๐ Dictionaries ๐ Keys & Values
Part A: Create a dictionary called pet with:
Print the dictionary.
Part B: Print a sentence using the values: "[name] is a [age] year old [type]"
Part C:
Example Output:
=== Part A ===
{'name': 'Whiskers', 'type': 'cat', 'age': 3, 'hunger': 50}
=== Part B ===
Whiskers is a 3 year old cat
=== Part C ===
{'name': 'Whiskers', 'type': 'cat', 'age': 3, 'hunger': 70, 'happy': True}
๐ Dictionaries ๐ For Loops
Part A: Create a dictionary called scores with:
Part B: Use a for loop to print each player and their score: "[player]: [score] points"
Part C: Find and print the highest score (you can do this manually by looking at the values - no need for max() function)
Example Output:
=== Part A & B ===
Alice: 250 points
Bob: 180 points
Charlie: 320 points
Diana: 200 points
=== Part C ===
Highest score: 320
๐ Dictionaries ๐ For Loops ๐ฅ Input ๐ Conditionals
Build a simple shop where you can buy items!
Step 1: Create a dictionary called shop:
Step 2: Create a variable money = 50 and print "You have [money] coins"
Step 3: Print all items and prices using a for loop
Step 4: Use a while loop to let the player shop:
if item in shop:if money >= shop[item]:Step 5: Print final money amount
Example Output:
You have 50 coins
=== SHOP ITEMS ===
apple: 5 coins
bread: 10 coins
fish: 15 coins
cake: 20 coins
Buy what? (or type 'quit'): apple
Bought apple! You have 45 coins left
Buy what? (or type 'quit'): cake
Bought cake! You have 25 coins left
Buy what? (or type 'quit'): fish
Bought fish! You have 10 coins left
Buy what? (or type 'quit'): bread
Bought bread! You have 0 coins left
Buy what? (or type 'quit'): apple
Not enough coins!
Buy what? (or type 'quit'): sword
We don't sell that!
Buy what? (or type 'quit'): quit
Final coins: 0
๐ก Tips:
dict_name[key]dict_name[key] = new_valueif key in dict_name:for key in dict_name:โ Standard library: heapq, collections, itertools, math, random, functools, datetime, bisect
โ Functions, classes, recursion, print()
โ No file system, subprocess, OS access, or network requests
โ No pip install (all supported modules are pre-loaded)
โฑ๏ธ 5 second execution time limit