Skip to lesson content
navan✳THE BUILD LABPYTHON 3
0/101 complete
BUILD LAB / PYTHON/ The essentials
EXPERIMENT 05 / 101

Make the numbers work.

Calculate totals, split work, and understand the result you are getting.

BY NAVAN SAMI◷ 6 MIN READPYTHON 3

01 The idea

Python has integers for whole numbers and floats for approximate decimal values. Arithmetic operators produce new values: + adds, * multiplies, / divides, // performs floor division, % gives a remainder, and ** raises a power. Pick the operation that matches the question.

02 The experiment

Read it once. Predict what will happen. Then copy it into a .py file and run it in your local Python setup.

numbers.py
assets = 17
per_batch = 5

print(assets // per_batch)
print(assets % per_batch)
print(2 ** 4)
print(assets / per_batch)
↳ EXPECTED OUTPUT
3
2
16
3.4

03 Under the hood

  1. 1

    17 // 5 gives three complete batches. With positive values, floor division tells us how many whole groups fit.

  2. 2

    17 % 5 gives two leftover assets. Together, quotient and remainder describe the split.

  3. 3

    Division with / produces a float here. Floats are approximate: for exact decimal accounting, investigate the decimal module rather than relying on binary floats.

04 Your turn, builder

A SMALL MISSION

You have 29 tasks and can finish 6 per day. Print the number of complete groups of 6 and the leftover tasks.

Reveal one possible solution +
one_possible_solution.py
tasks = 29
print(tasks // 6)
print(tasks % 6)

05 Check your signal

QUICK SIGNAL CHECK

What does 14 % 4 evaluate to?

THAT’S ANOTHER IDEA IN YOUR TOOLKIT.

Experiment. Logged.

When you can explain the idea and make the example your own, mark it complete. Your log stays in this browser.

Keep exploring

Go deeper with the official Python guide ↗.

Built with curiosity. By Navan Sami. ↗Python 3 · Think. Try. Build.