9.6.6 Worksheet 22

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

9.6.

6 Worksheet 22

An array called ‘coins’ contains up to 10


numbers. Each number represents how
much change Ahmad has got from a
visit to the shop.

Write a program in Python using


iteration that will loop 10 times to
add together all the values stored in
the array and then output the total.

The array contains the following values:


10 0 100 0 0 20 0 0 50 5

An example of what the program could


look like when run is shown below:
The total amount of change is 185

coins = [10, 0, 100, 0, 0, 20, 0, 0, 50, 5]


total_change = 0
for coin in coins:
total_change += coin
print("The total amount of change
is [total_change]")

You might also like