Quiz: The Piece Just Added
Someone built the same report in the same steps. After adding total_minutes(), they ran the program and checked both lines by hand: Walks: 5 and Time: 190 min were right. Then they pasted week_total() from an answer, added its line to print_report() and ran the program again:
Walks: 5
Time: 190 min
Total: 190
The walks cost 48. Click the line with the mistake.
1def walk_price(minutes):
2 half_hours = minutes // 30
3 if minutes % 30 > 0:
4 half_hours = half_hours + 1
5 return half_hours * 6
6
7def total_minutes(walks):
8 total = 0
9 for minutes in walks:
10 total = total + minutes
11 return total
12
13def week_total(walks):
14 total = 0
15 for minutes in walks:
16 total = total + minutes
17 return total
18
19def print_report(walks):
20 print("Walks:", len(walks))
21 print("Time:", total_minutes(walks), "min")
22 print("Total:", week_total(walks))
23
24walks = [30, 45, 20, 60, 35]
25print_report(walks)