Numbers and arithmetic
Section 2: Variables and inputLesson 2.2 · ⏱ 7 min
Adding +, taking away -, multiplying *, dividing /, and the remainder %.
apples = 17
friends = 5
print(apples / friends)
print(apples // friends)
print(apples % friends)
🖥️ The output in Robo Python:
🐍 Open the code in Robo Python ↗3.4 3 2

📌 Note
// divides with no fractions: each friend gets 3 apples, and % is what's left: two apples remain.📌 Another example: kinds of division
/ ordinary division, // with no fractions, and % the remainder.
print(17 / 5)
print(17 // 5)
print(17 % 5)
print(2 ** 10)
🖥️ The output in Robo Python:
🐍 Open the code in Robo Python ↗3.4 3 2 1024
✍️ Practise
Try the lesson's examples here: copy the code, change it, and click ▶ Run.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
The area of a rectangle 12 long and 7 wide.
👀 Show the solution🙈 Hide the solution
length = 12
width = 7
print(length * width)
🖥️ The output in Robo Python:
🐍 Open the code in Robo Python ↗84
Result: 84
Medium
You have 50 sweets and 6 friends: how many does each get, and how many are left?
👀 Show the solution🙈 Hide the solution
sweets = 50
friends = 6
print("each:", sweets // friends)
print("left:", sweets % friends)
🖥️ The output in Robo Python:
🐍 Open the code in Robo Python ↗each: 8 left: 2
Result: each: 8 and left: 2
Hard
How many seconds are in a day?
👀 Show the solution🙈 Hide the solution
print(24 * 60 * 60)
🖥️ The output in Robo Python:
🐍 Open the code in Robo Python ↗86400
Result: 86400

