thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

03.14 · Python basics / Practice · 6 min

Allocate whole tickets to each team

Eleven tickets must be shared equally among four teams. A team cannot receive a fraction of a ticket.

Activity 14 of 19 in Python basics

All courses

Python Basics / 03.14

Practice numbers

Not started

Use floor division for a whole-ticket allocation and remainder for the tickets left over.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Rob spots an allocation of 2.75 tickets per team for eleven tickets and four teams and investigates the division operator.
Rob’s comic strip · Python basics

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

6 steps · Saved work · Instant feedback

YOUR TURN

Give each team whole tickets

Keep tickets assigned to 11 and teams assigned to 4. Change per_team to calculate how many whole tickets each team receives using floor division. Keep leftover calculated with the remainder operator and keep both print calls. To pass: tickets must stay 11, teams must stay 4, per_team must hold 2, leftover must hold 3, and the program must print 2 then 3, once each. After passing, change the starting counts and predict the new result before running again.

Expected output
2
3

Keep the starting inputs. Print these lines in this order, without extra output.

  • tickets still holds 11
  • teams still holds 4
  • per_team holds 2 whole tickets
  • leftover holds 3 tickets

Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Need a nudge?

A fraction is the wrong answer to this question

The / operator returns a fractional quotient. Compare it with the operator that counts complete groups for these positive integers.

Check that every ticket is accounted for

Four teams receiving two tickets use eight tickets. The remainder is the three tickets still unallocated. Keep that calculation separate from per_team.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

You chose a whole-number quotient and kept the remainder. Type conversion is next in the original course order.