← Practice
πŸ“– Numbers and arithmeticLearning path
Browsing as guestΒ·Sign in or create a free account to save progress and use tutor tools.
LessonΒ·difficulty 1/5Β·~7 min

Share the cookies

When you split things into equal groups, two questions come up: how many does each group get? and how many are left over? Python has one operator for each:

  • // β€” whole-number divide (how many fit in each group)
  • % β€” the remainder (what's left over)
python
print(17 // 5)   # 3
print(17 % 5)    # 2

Your task

You have 17 cookies to share equally among 5 friends.

  1. each β€” how many whole cookies each friend gets. Which operator splits into equal whole groups?
  2. leftover β€” how many cookies don't fit into a full group. Which operator gives the remainder?

You've seen // and % in action above β€” now use them on cookies and friends to fill in each and leftover yourself, then print(each, leftover).

Sanity check: each * friends + leftover should add right back up to cookies. That identity is true for any numbers you plug in.

Tests

  • each friend gets 3 whole cookies
  • 2 cookies are left over

✦ Stuck? Ask for a spark

Sign in or create a free account to use your monthly AI explainer allowance.

warming up
Loading editor…
Consolewaiting

$ Console output will appear here.

>_AI coach
Sign in or create a free account to chat with the tutor.