Practice Session (On Sport Question)
Organize your school supplies and practice simple math in Python.
1. How many notebooks do you have? Hint: Use input() and int().
2. How many pens do you have? Hint: Same as above.
1. Find the total items you have. Hint: Use + operator.
2. Check if you have more notebooks than pens. Hint: Use if notebooks > pens:
3. Check if notebooks are more than twice the pens. Hint: Use if notebooks > 2 * pens:
Print a short message like: "Great job organizing your school supplies!"
Use your pocket money to check what school supplies you can buy.
1. How much money do you have? Hint: Use input() and int().
2. How much does one notebook cost? Hint: Same way as above.
3. How much does one pen cost? Hint: Same way as above.
1. Can you afford at least 1 notebook? Hint: Use if money >= notebook_price:
2. Can you afford 5 notebooks? Hint: Multiply price × 5.
3. If you don’t have enough for even 1 notebook, print "Save more money!"
Print a short message like: "Shopping is fun when you plan your money!"
Buy notebooks and pens together, and check if your pocket money is enough.
# Big School Supplies Game
notebook_price = int(input("Price of one notebook: "))
pen_price = int(input("Price of one pen: "))
money = int(input("How much pocket money do you have? "))
notebooks = int(input("How many notebooks do you want? "))
pens = int(input("How many pens do you want? "))
# Calculate total cost
total_cost = (notebook_price * notebooks) + (pen_price * pens)
print("Final Bill:", total_cost)
# Compare with money
if money > total_cost:
print("You can pay! Money left:", money - total_cost)
elif money == total_cost:
print("You spent all your money!")
else:
print("Not enough money. You need more:", total_cost - money)
Inputs:
Price of one notebook: 20
Price of one pen: 5
How much pocket money do you have? 100
How many notebooks do you want? 3
How many pens do you want? 4
Output:
Final Bill: 80
You can pay! Money left: 20