Skip to content

hlanchas/Programming-exercise-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Programming-exercise-3

Story

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.

Objectives

  • 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.

Instructions

Part 1: The Mix-Up (Swapping Strings)

The Alchemist has two bottles.

  • The bottle labeled label_1 contains "Poison".
  • The bottle labeled label_2 contains "Health Potion".
  • Task: Write code to SWAP the contents so label_1 has the Potion and label_2 has the Poison.

Part 2: Shopping Spree (Updating Stats)

Your Hero (from Assignment 2) enters the shop.

  • Print the stats before buying.
  • Task: Create variables for gold (50.0) and inventory_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.

Part 3: The Magic Gate (Boolean Logic)

To leave the shop, you must pass the Magic Gate. The gate only opens if:

  1. Your magic_level is greater than 10.
  2. AND you have the gate_key (True).
  • Task: Create these variables, and then create a boolean variable called can_pass. Print can_pass (it should be True or False).

Part 4: The Riddle (Odd or Even?)

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 is 1, it is Odd.

How to Submit

  1. Run your code in Thonny.
  2. Ensure you see the swapped labels, updated gold, and the result of the riddle.
  3. Upload main.py to GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors