Lab · Python Programming
Lab: saving for a scooter
The brief
Asha saves a little more every month to buy a scooter. Use for loops, a while loop, continue and a counting loop to plan her savings.
Why it matters
Recurring deposits, SIPs and EMI tables are all loops: the same sum done once per month. Banks, finance apps and anyone planning a big purchase work out "how much by when" and "how many months until" exactly like this.
Skills you practise
- for loops with range()
- while loops
- continue
- accumulator and counter patterns
What you will have at the end
savings.py: a savings planner that prints the year's total, the months needed for the scooter, the total with a month off and the count of big months.
How it is marked (rubric, 100 points)
| Correct resultsAll four checks pass: 24600, 18 months, 22200 and 7. | 50 |
|---|---|
| Right loop for the jobfor with range() when the count is known, while when it is not, continue to skip one round. | 25 |
| Accumulators set up properlyEach total or counter starts at 0 before its loop and changes inside it. | 15 |
| Readable outputEvery result is printed with a short label. | 10 |
0/4 steps done
Step 1 of 4
One year of savings
total_year holds what Asha saves in months 1 to 12 (24600 rupees).
In month m she saves first_month + step_up * (m - 1). So month 1 is 1500 and month 12 is 2600. range(1, 13) gives the months 1 to 12; the stop number 13 is not included. Start total_year at 0 before the loop and add each month's saving inside it.
Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.