Quarry School

Keep a remainder — quick review

In plain words

You have a stack of 38 postcards and display sleeves that hold six cards each.

Rule

The total is how many items you start with. It can be any whole number from zero up. The group size is how many items fit in one full group. It can be any whole number from one up. Here, whole numbers are the counts 0, 1, 2 and so on.

Put the total on the left and the group size on the right. With // between them, Python gives the number of full groups. With % between them, it gives the remainder. The remainder is smaller than the group size. When it is zero, the full groups use all the items.

Step

  1. Write down the total and the group size.

  2. Use // between those numbers to find the number of full groups.

  3. Use % between the same numbers to find the remainder.

  4. Multiply the group count by the group size and add the remainder. Check that you get the total and that the remainder is smaller than one full group.

  5. When you type the program, cards = 38 gives the name cards the value 38. The line cards_per_sleeve = 6 gives the group size its own name, with underscores between the words.

Trap

If you catch yourself reading % as “percent,” read 38 % 6 aloud as “How many cards are left?” Its answer counts two loose cards. If you swap the two results, you get two full sleeves and six loose cards. Six loose cards would fill one more sleeve, so the swap fails the remainder check.