TalentJR

🐍 Python for kids · Class 5 · Lesson 3 of 18 · Free

Basic Arithmetic Operations

⏱ About 25 minutes · ▶ run real Python here — nothing to install · no sign-in

In this lesson you will

  • Add, subtract, multiply and divide with Python
  • Find a quotient with // and a remainder with %
  • Use brackets to control the order of a sum

Your class has 17 laddoos to share among 5 friends. How many does each friend get, and how many are left over? You could work it out on paper. Or Python can do it in a blink!

How does Python do maths?

Python is a super-fast calculator. The signs it uses are called operators.

+ adds and - subtracts. For multiply, Python uses a star *, because x is a letter.

For divide, Python uses a slash /. Look closely at the answer of the division.

🐍 Python — you can edit this code
Output
42
42
42
42.0

💡 The / sign always gives a float, like 42.0, even when the answer is a whole number.

What do // and % do in Python?

Sometimes you want whole things only. You cannot give a friend half a laddoo!

// is floor division. It divides and keeps only the whole part of the answer.

% is the remainder sign. It tells you what is left over after sharing equally.

Check it like your maths teacher would. 5 friends × 3 laddoos = 15, and 15 + 2 = 17. Correct!

🎬 How Python thinks — step 1 of 7Python is about to run line 1
▶laddoos = 17
2friends = 5
3each = laddoos // friends
4left = laddoos % friends
5print("Each friend gets", each)
6print("Left over:", left)
📦 Variables (memory boxes)

No variables yet.

🖥️ Output
▌
✏️ Change this code and run it yourself
🐍 Python — you can edit this code
Output
Each friend gets 3
Left over: 2

💡 % is very useful later. A number % 2 gives 0 for even numbers and 1 for odd numbers.

What does ** mean in Python?

** means "to the power of". So 5 ** 2 means 5 × 5, which is 25.

It saves you from writing long multiplications. 2 ** 10 is ten 2s multiplied together.

Powers are handy for squares. A square classroom with 8-metre sides has an area of 8 ** 2 square metres.

🐍 Python — you can edit this code
Output
25
27
1024
Area: 64 square metres

💡 Two stars mean power. One star means multiply. Do not mix them up!

In what order does Python do maths?

Python follows the same rule as your maths book: BODMAS.

First come brackets, then powers. Next come *, /, // and %. Last come + and -.

If you want something done first, put it in brackets. Brackets also make code easier to read.

🐍 Python — you can edit this code
Output
20
30
11
95.0

💡 Signs at the same level, like * and /, are done from left to right.

How do I use variables in maths?

Real programs store numbers in variables, then do maths with them.

Good names make the sum easy to follow. Here, a canteen bill is worked out step by step.

Change the number of samosas and run it again. Every answer updates by itself.

🎬 How Python thinks — step 1 of 8Python is about to run line 1
▶samosa_price = 15
2samosas = 4
3juice_price = 20
4total = samosa_price * samosas + juice_price
5change = 100 - total
6print("Total bill:", total, "rupees")
7print("Change from 100:", change, "rupees")
📦 Variables (memory boxes)

No variables yet.

🖥️ Output
▌
✏️ Change this code and run it yourself
🐍 Python — you can edit this code
Output
Total bill: 80 rupees
Change from 100: 20 rupees

What does += do in Python?

Often you add something to a variable and store it back, like runs = runs + 4.

Python has a short way to write this: runs += 4. It means exactly the same thing.

There are also -= and *= for subtracting and multiplying.

🎬 How Python thinks — step 1 of 9Python is about to run line 1
▶runs = 0
2runs += 4
3runs += 6
4runs += 1
5print("Total runs:", runs)
6balls_left = 6
7balls_left -= 3
8print("Balls left:", balls_left)
📦 Variables (memory boxes)

No variables yet.

🖥️ Output
▌
✏️ Change this code and run it yourself
🐍 Python — you can edit this code
Output
Total runs: 11
Balls left: 3

🤔 Predict the output

Think like Python: read the code and choose what it prints. You get the reason straight away.

Question 1. What does this print?

print(7 // 2, 7 % 2)

Question 2. What does this print?

print(2 + 3 * 4)

Question 3. What does this print?

x = 10
x += 5
print(x / 5)

🧩 Your challenge

Pizza party! There are 23 pizza slices and 4 friends. Work out how many slices each friend gets, and how many are left over. Then find the total cost if each slice costs 35 rupees.

Expected output :
Each friend gets 5 slices
Slices left over: 3
Total cost: 805 rupees
🐍 Python — you can edit this code

⚠️ Common mistakes (and how to fix them)

❌ Wrong

average = 80 + 90 / 2
print(average)

No error – but the average is 125.0 instead of 85.0.

✅ Right

average = (80 + 90) / 2
print(average)

Python divides before it adds. Put the sum in brackets so it is added first.

❌ Wrong

print(5 x 3)

SyntaxError: invalid syntax. Perhaps you forgot a comma?

✅ Right

print(5 * 3)

x is a letter in Python. Use the star * to multiply.

❌ Wrong

sweets = 12
kids = 0
print(sweets / kids)

ZeroDivisionError: division by zero

✅ Right

sweets = 12
kids = 3
print(sweets / kids)

Nobody can divide by zero, not even Python. Make sure the number you divide by is not 0.

📌 Remember

  • Python uses + - * / for add, subtract, multiply and divide.
  • / always gives a float, like 5.0.
  • // gives the whole part of a division, and % gives the remainder.
  • ** means power: 2 ** 3 is 8.
  • Python follows BODMAS; use brackets to choose what happens first.
  • runs += 4 is a short way to write runs = runs + 4.

Finished the quiz and the challenge?

Questions students ask

What is the difference between / and // in Python?

/ gives the exact answer as a float, so 7 / 2 is 3.5. // keeps only the whole part, so 7 // 2 is 3.

What does % mean in Python?

% gives the remainder after dividing. For example, 17 % 5 is 2, because 5 goes into 17 three times with 2 left over. It is not percentage.

Does Python follow BODMAS?

Yes. Brackets come first, then powers, then multiply and divide, then add and subtract. Use brackets whenever you are unsure.

Why does 10 / 2 give 5.0 and not 5?

In Python 3, the / sign always gives a float. Use // if you want a whole number answer.