You have arrived at the village Alchemist's shop. However, the shopkeeper is messy! He has mixed up his labels, and he needs your help to organize the shop, sell items to your hero, and solve a math riddle to open the Magic Gate.
- Swap Variables: Switch data between two variables using a temporary box.
- Update Variables: Change values based on math (spending gold).
- Modulo Operator (%): Calculate remainders to find odd/even numbers.
- Boolean Logic: Check if you meet the requirements to enter the gate.
The Alchemist has two bottles.
- The bottle labeled
label_1contains "Poison". - The bottle labeled
label_2contains "Health Potion". - Task: Write code to SWAP the contents so
label_1has the Potion andlabel_2has the Poison.
Your Hero (from Assignment 2) enters the shop.
- Print the stats before buying.
- Task: Create variables for
gold(50.0) andinventory_count(5). - The hero buys a sword for 15.5 gold.
- Subtract the cost from
gold. - Add 1 to
inventory_count. - Print the new stats.
To leave the shop, you must pass the Magic Gate. The gate only opens if:
- Your
magic_levelis greater than 10. - AND you have the
gate_key(True).
- Task: Create these variables, and then create a boolean variable called
can_pass. Printcan_pass(it should be True or False).
The Gatekeeper asks: "Is the number 743 odd?"
- Task: Create a variable
mystery_number = 743. - Calculate if it's odd or even.
- Print the result.
- Note: If the result is
0, it is Even. If the result is1, it is Odd.
- Run your code in Thonny.
- Ensure you see the swapped labels, updated gold, and the result of the riddle.
- Upload
main.pyto GitHub.