← Practice
πŸ“– Numbers and arithmeticLearning path
Browsing as guestΒ·Sign in or create a free account to save progress and use tutor tools.
LessonΒ·difficulty 1/5Β·~6 min

Shopping total

Python is a calculator that remembers. Store numbers in names, then do math with the names:

python
seats = 4
ticket = 250
bill = seats * ticket   # 1000

Your task

You're buying 3 notebooks at β‚Ή45 each, and you walked in with a budget of β‚Ή200.

  1. total β€” the cost of all the notebooks.
  2. left β€” how much of your budget is left after buying them.

The seats Γ— ticket example shows the pattern β€” apply it with price, quantity, and budget, then print(total, left). Give it a real go before asking the tutor for a spark.

Notice you can reuse total when you compute left β€” that's the "remembers" part. Change quantity to 5 and re-run to see both numbers update.

Tests

  • total is 3 notebooks x 45
  • left is the budget minus the total

✦ Stuck? Ask for a spark

Sign in or create a free account to use your monthly AI explainer allowance.

warming up
Loading editor…
Consolewaiting

$ Console output will appear here.

>_AI coach
Sign in or create a free account to chat with the tutor.