Press ▶ Run to see what your program does.
Lesson 27: Numbers and maths
Level 4, Python First Steps. Add, take away, times, and two kinds of divide. The new word: operator. It follows lesson 26, Variables: boxes with labels. Next comes lesson 28, Programs that listen (input).
What the lesson explains
Numbers and maths. Python is a very fast calculator.
+ - and two kinds of /. The signs are called operators. means times. 10 / 4: 2.5; 10 // 4: 2; 10 % 4: 2 left.
What you do first
Times tables. Print 6 times 7. One way to write it: print(6 * 7). It prints: 42.
The code on the screen
+ - and two kinds of /. The editor shows 3 lines: print(10 / 4) / print(10 // 4) / print(10 % 4). Run it, and it prints "2.5", "2", "2".
What is left over?. The editor shows one line: print(7 % 2). Run it, and it prints "1".
What you practise
Try it, "Times tables": Print 6 times 7. One way to write it: print(6 * 7). It prints: 42. Then: Share 12 apples between 4 friends. The editor opens with: apples = 12 / friends = 4. One way to write it: apples = 12 / friends = 4 / print(apples // friends). It prints: 3.
Fix it, "Words and numbers": Print Age: 10. The editor opens with: age = 10 / print("Age: " + age). One way to write it: age = 10 / print("Age: " + str(age)). It prints: Age: 10.
In your head, "What is left over?": print(7 % 2): what does it print? The answer: "1".
What PlayBuddy and PlayType say
PlayBuddy: "Computers are super fast at maths. Let’s make Python do the sums!"
PlayType: "One slash gives a decimal answer. Two slashes give a whole number."
Help in every lesson
Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.
A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.
Stars
The lesson has 4 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.
About DayOneCode
DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.