──────────────────────────────────────

12. Measure and Plan with Numbers · Build a Water Refill Planner

Check two measurements and calculate how many bottle fills cover a water target.

Lesson files · lessons/numeric-tools/water-refill-planner

Before you start
- Check whether a number falls within inclusive limits.
- Divide to convert a quantity or find an equal share.
- Format a decimal result with two places.

By the end
- Use and to check the target and capacity before dividing.
- Use ceil() to count a partial fill.
- Test a partial fill, an exact fit and an invalid capacity.

Where you can use it
Plan how many boxes you need for art supplies. Divide the number of kits by the box capacity and count a partly filled box too.

To carry 1250 mL in a 500 mL bottle, a gardener needs two full fills and one partial fill. The division gives 2.5. A call to ceil(2.5) counts 3 fills, and ceil(2.0) gives exactly 2. Keep the line from math import ceil at the top of the program so you can use ceil().

Check each range and give the two results names. The condition target_ok and bottle_ok is True only when both checks pass. Divide in that branch to avoid dividing by zero.

To display the amount planned, divide the target in millilitres by 1000 to convert to litres, then show two decimal places.

Predict
How many boxes do you need if you change tiles to 12?
- 3
- 2

Worked example (example.py)

from math import ceil

tiles = 13
tiles_per_box = 6
boxes = ceil(tiles / tiles_per_box)
print(f"Boxes needed: {boxes}")


Example result
Boxes needed: 3

Read two whole numbers on separate lines. The first is the water target in mL from 0 to 10000 inclusive. The second is the bottle capacity in mL from 250 to 2000 inclusive. If either value is outside its range, print Out of range. For valid inputs, count all fills including a partial final fill. Print Fills needed: 3 and Water planned: 1.25 L on separate lines for a target of 1250 and a capacity of 500. Show the target in litres to two decimal places.

Starter program (starter.py)

from math import ceil
target_ml = int(input())
bottle_ml = int(input())
# Check the measurements before calculating the fills.
print(f"{target_ml} mL requested")


Starter input
1250
500

Hint
Check the ranges first. In the valid branch, apply ceil() to the target divided by the capacity and use a separate conversion to get litres.

Case 1. Try the sample
Input
1250
500
Expected output
Fills needed: 3
Water planned: 1.25 L

Case 2. Exact fills at the limits
Input
10000
2000
Expected output
Fills needed: 5
Water planned: 10.00 L

Case 3. Zero capacity
Input
750
0
Expected output
Out of range

Project checklist
Run the sample case.

Project checklist
Try one different case and explain what happened.

Marking criterion
Program behaviour (4 points)
Each required behaviour works on the supplied cases.

Marking criterion
Use of the lesson concept (3 points)
The code uses the main idea in a clear, purposeful way.

Marking criterion
Test evidence (2 points)
The reflection describes a case, its expected result and what happened.

Marking criterion
Explanation (1 points)
The learner explains a change or design decision in their own words.

Stretch
Try a zero target. Then report the millilitres in the last fill whenever the plan needs at least one fill. Test one full and one partial last fill.

Reflect
Why does a partial last fill count as a whole fill in your report?

Check your prediction
2 Twelve tiles fill two boxes exactly. ceil(2.0) gives 2.
