Skip to main content
🐍 Python Basics 🐍

What's Left Over? βž—

Sometimes you want to know what's left over after sharing. Python's % (say "remainder") does exactly that:

7 % 2   # 1  β†’ 7 shared in 2s leaves 1 left over
6 % 2   # 0  β†’ 6 shares evenly, nothing left over
10 % 3  # 1  β†’ 10 shared in 3s leaves 1

So % tells you the leftover amount. It's handy for "is this even?" checks and lots more.

Your task

Write remainder(a, b) that returns what's left over when you divide a by b β€” that's a % b.

⚑ 25 XP

🧱 Code blocks

Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.

solution.pyRuns in your browser (Pyodide)
Loading editor…
Tests3 to pass
7 % 2 == 1
6 % 2 == 0
10 % 3 == 1

Run your code to check these.