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

9. Measure and Plan with Numbers · Convert a Measurement

Read a decimal measurement and express it in a different unit.

Lesson files · lessons/numeric-tools/convert-a-measurement

Before you start
- Convert input to a whole number with int().
- Multiply a count by a fixed amount and label the result.

By the end
- Use float(input()) to read a measurement with a decimal point.
- Explain why the number grows when the unit changes from litres to millilitres.
- Test the conversion with a fraction of a litre and with zero.

Where you can use it
Compare a plant’s height with a chart that uses centimetres. Convert a reading in metres first so the numbers use the same unit.

A measuring tape might show 1.75 metres. Use a decimal point when you enter a fractional measurement like 1.75. float(input()) reads the line and converts the text to a number you can multiply.

There are 100 centimetres in a metre, so multiply the measurement in metres by 100 to get the value in centimetres. Include the unit in each variable name and in the output. The next lesson shows how to control how many decimal places appear.

Predict
What happens to the number when you change from metres to centimetres?
- It becomes 100 times as large.
- It becomes 100 times as small.

Worked example (example.py)

metres = float(input())
centimetres = metres * 100
print(f"{centimetres} cm")


Example input
1.75

Example result
175.0 cm

Read one non-negative decimal measurement in litres. Convert it to millilitres and print the number followed by a space and mL. Use Python’s default float display, so 1.25 L appears as 1250.0 mL.

Starter program (starter.py)

litres = float(input())
# Calculate the amount in millilitres here.
print(f"{litres} L")


Starter input
1.25

Hint
There are 1000 millilitres in a litre. Store the converted number in a new variable and use it in the f-string.

Case 1. Try the sample
Input
1.25
Expected output
1250.0 mL

Case 2. Part of a litre
Input
0.125
Expected output
125.0 mL

Case 3. Empty measure
Input
0
Expected output
0.0 mL

Stretch
Divide the millilitres by 1000 to convert back to litres. Compare the result with your starting measurement.

Reflect
How do your variable names tell you which number to print?

Check your prediction
It becomes 100 times as large. Each metre contains 100 centimetres, so the same length needs a larger number of centimetres.
