Simple Word Problems
A word problem is solved in four moves: name the unknown, write down what the text says about it as an equation, solve the equation, and check the answer against the original story. This lesson works through the common patterns (consecutive numbers, ages, money, distance–rate–time and mixtures) and shows how to check them in Python.
The four-step method
| Step | Question to ask | Example: "A shop sells 3 times as many mugs as plates; 84 items in total." |
|---|---|---|
| 1. Name | What exactly is unknown? Give it a letter. | |
| 2. Express | Write every other quantity in terms of that letter. | |
| 3. Equate | Which sentence gives an equation? | |
| 4. Solve and check | Does the answer fit the story? | , , ✓ |
Tip: Write a "let" line () every time. Half the battle in word problems is being clear about what the letter means, including its unit.
Consecutive numbers
"Three consecutive whole numbers add up to 72." Consecutive numbers differ by 1, so if the first is , the others are and .
For consecutive even or odd numbers the step is 2: , , .
Ages
"Lena is 4 times as old as her brother. In 6 years she will be twice as old as him. How old are they now?"
Money and rates
"A streaming plan costs €8 per month; a rival costs €5 per month plus a €27 setup fee. After how many months do they cost the same?"
After 9 months both have cost €72; after that, the rival is cheaper. A "break-even" question is always an equation that sets two costs equal.
Distance, rate and time
The rule is (). "Two cyclists start 54 km apart and ride toward each other at 20 km/h and 16 km/h. When do they meet?" Together they close the gap at :
SymPy can check all four problems in one go:
from sympy import symbols, Eq, solve
n, b, m, t = symbols("n b m t")
print("consecutive:", solve(Eq(n + (n + 1) + (n + 2), 72), n))
print("ages: ", solve(Eq(4*b + 6, 2*(b + 6)), b))
print("break-even: ", solve(Eq(8*m, 5*m + 27), m))
print("cyclists: ", solve(Eq(20*t + 16*t, 54), t))consecutive: [23]
ages: [3]
break-even: [9]
cyclists: [3/2]
Mixtures and averages
"A student scored 72 and 85 on two tests. What score on the third gives an average of 80?"
Checking by simulation
A good habit for programmers: check an answer by simulating the story rather than re-solving the equation. Here the break-even problem is simulated month by month:
plan_a, plan_b = 0, 27
for month in range(1, 13):
plan_a += 8
plan_b += 5
marker = " <- equal" if plan_a == plan_b else ""
if month in (8, 9, 10):
print(f"month {month}: A = {plan_a}, B = {plan_b}{marker}")month 8: A = 64, B = 67
month 9: A = 72, B = 72 <- equal
month 10: A = 80, B = 77
In software
Word problems are what product requirements look like. "Free tier allows 1000 requests per day; paid tier is €0.002 per request above that; at what usage does a €10 flat plan win?" is the break-even pattern. "Two players move toward each other at known speeds; when do they collide?" is distance–rate–time, which the collision timing lesson extends to quadratic motion.
Exercises
Exercise 1: Consecutive odd numbers
Three consecutive odd numbers add up to 99. Find them.
Answer
31, 33, 35
Solution
Exercise 2: Coins
A jar has only 20-cent and 50-cent coins, 30 coins in all, worth €10.20. How many of each?
Answer
14 coins of 50 cents and 16 coins of 20 cents.
Solution
Work in cents. Let , so are 20-cent coins.
So there are 14 coins of 50 cents and coins of 20 cents. Check: cents ✓.
from sympy import symbols, Eq, solve
f = symbols("f")
fifty = solve(Eq(50*f + 20*(30 - f), 1020), f)[0]
print(fifty, 30 - fifty)14 16
Exercise 3: Catch-up
A delivery van leaves a depot at 60 km/h. Half an hour later a car leaves the same depot on the same road at 90 km/h. How long after the car starts does it catch the van?
Answer
1 hour (both are 90 km from the depot).
Solution
Let . The van has driven hours. They meet when distances are equal:
Exercise 4: Simulate the story
Write a loop that simulates Exercise 3 in steps of 0.25 h of the car's driving time and prints the first time the car's distance is at least the van's.
Answer
1.0 hours
Solution
t = 0.0
while 90 * t < 60 * (t + 0.5):
t += 0.25
print(t, "hours")1.0 hours
Test yourself
If is the first of three consecutive even numbers, the third is:
Plan A costs €12/month. Plan B costs €7/month plus €40 up front. When are they equal?
- After 5 months
- After 8 months
- After 4 months
- Never
Two trains 300 km apart approach each other at 70 km/h and 80 km/h. When do they meet?
- 1.5 h
- 2 h
- 3 h
- 4.3 h