Place Value and Rounding
In the number 4,072 the digit 7 means seventy, not seven, because of where it stands. This idea, place value, is what lets ten digits write every number. Rounding builds on it: it replaces a number with a nearby, simpler one by keeping only the places that matter.
Places are powers of ten
Our system is base ten (decimal): each place is worth ten times the place to its right.
| Place | Ten thousands | Thousands | Hundreds | Tens | Ones |
|---|---|---|---|---|---|
| Value | 10 000 | 1 000 | 100 | 10 | 1 |
| Power of ten | |||||
| Digits of 52 708 | 5 | 2 | 7 | 0 | 8 |
Reading the table as a sum gives the expanded form:
The 0 in the tens place matters: it holds the place so the 7 stays in the hundreds. Without zero, 52 708 and 5 278 would look the same. (Places to the right of the decimal point, tenths and hundredths, continue the pattern; they get their own lesson in Decimal Place Value.)
Large numbers are grouped in threes so they are easy to read: 7 400 000 000 is "seven billion four hundred million". Different countries use commas, points or thin spaces as the separator. Python accepts underscores in code and can print commas:
population = 7_400_000_000
print(population)
print(f"{population:,}")
n = 52708
digits = [int(d) for d in str(n)]
places = [10 ** p for p in range(len(digits) - 1, -1, -1)]
for d, p in zip(digits, places):
print(f"{d} x {p:>6} = {d * p:>6}")
print("sum =", sum(d * p for d, p in zip(digits, places)))7400000000
7,400,000,000
5 x 10000 = 50000
2 x 1000 = 2000
7 x 100 = 700
0 x 10 = 0
8 x 1 = 8
sum = 52708
Getting one digit with // and %
Integer division and remainder pick digits out of a number without turning it into text. n // 10 drops the last digit; n % 10 keeps only the last digit. To get the hundreds digit, first divide by 100, then take the last digit:
n = 52708
print("ones: ", n % 10)
print("tens: ", n // 10 % 10)
print("hundreds: ", n // 100 % 10)
print("thousands:", n // 1000 % 10)ones: 8
tens: 0
hundreds: 7
thousands: 2
Rounding
To round a number to a chosen place:
- Find the digit in that place (the rounding digit).
- Look at the digit just to its right.
- If that digit is 5 or more, add 1 to the rounding digit (round up); if it is 4 or less, leave it (round down).
- Replace all digits to the right with zeros.
Round 52 708 to the nearest hundred:
hundreds digit = 7, next digit = 0 → keep 7 → 52 700
Round 52 708 to the nearest thousand:
thousands digit = 2, next digit = 7 → 2 becomes 3 → 53 000
Round 3 960 to the nearest hundred:
hundreds digit = 9, next digit = 6 → 9 becomes 10, carry → 4 000On the number line, rounding to the nearest hundred means "which multiple of 100 is closer?" 52 708 is 8 away from 52 700 and 92 away from 52 800, so it rounds to 52 700. A number exactly halfway, such as 250, is the only tricky case.
Python's rounding and the halfway case
round(x, -2) rounds to the nearest hundred (a negative number of digits means places left of the decimal point). But for exact halves, Python uses round half to even: it picks whichever neighbour has an even rounding digit. Schools teach round half up. The decimal module can do either:
from decimal import Decimal, ROUND_HALF_UP
print(round(52708, -2), round(52708, -3))
for n in [250, 350, 450]:
school = Decimal(n).quantize(Decimal("1E2"), rounding=ROUND_HALF_UP)
print(n, "python:", round(n, -2), " school:", int(school))52700 53000
250 python: 200 school: 300
350 python: 400 school: 400
450 python: 400 school: 500
Why would anyone round halves to even? If you round many halves always up, totals drift upward. Rounding half to even goes up half the time and down half the time, so errors cancel. Banks and statistics software often use it for that reason.
Tip: When a result must match a school worksheet or a legal rule (taxes, invoices), use
Decimalwith an explicit rounding mode instead ofround.
Estimating
Rounding first makes mental arithmetic easy and catches mistakes: is about . If your calculator shows 79 900, you know a key slipped.
In software
- Displaying numbers: dashboards show "1.2k followers" or "3.4 MB", which is rounding to a chosen place.
- Digit tricks with
// 10and% 10appear in checksums (credit card numbers, ISBNs), digit-sum puzzles and converting numbers to text by hand. - Other bases follow the same rule with a different base: binary places are 1, 2, 4, 8, …, which you will see in Binary and Hexadecimal.
Exercises
Exercise 1: Expanded form
Write 30 495 in expanded form and name the place of the digit 9.
Answer
; the 9 is in the tens place.
Solution
Read the digits from left to right with their place values: 3 ten-thousands, 0 thousands, 4 hundreds, 9 tens, 5 ones. The 9 means 90.
Exercise 2: Round three ways
Round 68 451 to the nearest ten, hundred and thousand.
Answer
68 450, 68 500, 68 000
Solution
nearest ten: tens digit 5, next digit 1 → keep → 68 450
nearest hundred: hundreds digit 4, next 5 → 4 becomes 5 → 68 500
nearest thousand: thousands digit 8, next 4 → keep → 68 000n = 68451
print(round(n, -1), round(n, -2), round(n, -3))68450 68500 68000
No exact halves here, so Python's rule and the school rule agree.
Exercise 3: The carry
Round 9 962 to the nearest hundred.
Answer
10 000
Solution
The hundreds digit is 9 and the next digit is 6, so the 9 rounds up to 10. That carries 1 into the thousands: . Result 10 000 (check: 9 962 is 38 away from 10 000 and 62 away from 9 900).
Exercise 4: Digit sum
Write a loop that adds up the digits of 52 708 using only % 10 and // 10.
Answer
Solution
Take the last digit with % 10, add it, then remove it with // 10; stop when nothing is left.
n = 52708
total = 0
while n > 0:
total += n % 10
n //= 10
print(total)22
Test yourself
In 6 4 8 1 3, what is the value of the digit 8?
- 8
- 80
- 800
- 8 000
What is 7 349 rounded to the nearest hundred?
- 7 300
- 7 400
- 7 000
- 7 350
Python's round(2500, -3) returns 2000, not 3000. Why?
- It always rounds down
- It rounds an exact half to the even neighbour
- It is a bug
- Negative digits are not allowed