Level 06: count controlled iterations and scope 0 of 9 activities solved
  1. 1. Countdown to launch Not yet solved
  2. 2. Rainfall Not yet solved
  3. 3. Notebook Not yet solved
  4. 4. Times tables Not yet solved
  5. 5. Voting count Not yet solved
  6. 6. Fizz Buzz Not yet solved
  7. 7. Find and replace Not yet solved
  8. 8. Twelve days of Christmas Not yet solved
  9. 9. Distribution of two dice Not yet solved
Next series Assessment point: levels 01-06
Level 06: count controlled iterations and scope

2. Rainfall

Sign in to hand in your solution and get feedback.

# Rainfall program # ------------------------- # Subprograms # ------------------------- def analyse1(data): count = 0 for value in data: if value == 0: count = count + 1 return count def analyse2(data): count = 0 for index in range(len(data)): if data[index] == 0: count = count + 1 return count # ------------------------- # Main program # ------------------------- daily_rainfall_mm = [0.1, 0.0, 0.2, 0.4, 0.1, 0.0, 0.0, 0.0, 0.3, 0.3, 0.2, 0.0, 0.0, 0.1] print("Days with no rain:", analyse1(daily_rainfall_mm))