Question 12
What is the output of the following code? [3 marks]
Solution
Variables balance and interest with values 5000 and 1.6 respectively are declared.
| Count | Count < 2? | New balance: balance *= (1 + interest/100) |
|---|---|---|
| 0 | True |
5000 * (1 + 1.6/100) = 5080 |
| 1 | True |
5080 * (1 + 1.6/100) = 5161.28 |
| 2 | False |
5161.28 (exit loop) |
At the end, the integer value of balance is printed, i.e., int(5161.28) = 5161.