Chapter 0 · Section 6 practice

Put the Pieces Together

Work from question 1 to 10. Write your code, click Run Code, review the result, then click Submit attempt. An attempt may be wrong: reference answers become available after you submit all 10. Each Python box is independent. Submission progress is saved in this browser.

Submitted: 0 / 10

1. Represent a percentage

Warm-up. Store 5% as a numeric rate. Print the rate and 5% of HK$200.

Write your answer, then run it.

2. One year of growth

Warm-up. Starting at HK$1000, calculate the balance after one year at an assumed 5% growth. Print two decimals.

Write your answer, then run it.

3. A negative year

Warm-up. Start at HK$1000 and apply a 10% decrease. Print the updated balance with two decimals.

Write your answer, then run it.

4. Use a power

Build your skills. Calculate HK$1000 growing at an assumed 10% per year for 3 years using **. Print two decimals.

Write your answer, then run it.

5. Trace the three years

Build your skills. Use a loop to calculate the same growth as the previous question. Print the year and updated balance each time.

Write your answer, then run it.

6. Compare scenarios

Build your skills. For HK$1000 over 2 years, loop over assumed rates -0.10, 0, and 0.10. Print each rate as a percentage and the final amount.

Write your answer, then run it.

7. Changing annual rates

Build your skills. Start at HK$1000. Apply annual rates 10%, -10%, and 5% in that order. Print the balance after each year.

Write your answer, then run it.

8. Add a deposit at year-end

Challenge. Start at HK$1000. In each of 2 years, first grow the balance by 5%, then add a HK$200 deposit at year-end. Print both year-end balances.

Write your answer, then run it.

9. Growth followed by an annual fee

Challenge. Start at HK$1000. Each year for 2 years: grow by 5%, then subtract a fixed HK$10 fee. Define a function for one year and call it inside the loop. Print each balance.

Write your answer, then run it.

10. Check a savings goal under assumptions

Challenge. Start at HK$1000, apply rates [0.10, -0.10, 0.05], then print the final balance and Goal met if it is at least HK$1050, otherwise Below goal. Add a Python comment explaining why this is not a forecast.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.