Level 06: count controlled iterations and scope 0 van 9 activiteiten opgelost
  1. 1. Countdown to launch Nog niet opgelost
  2. 2. Rainfall Nog niet opgelost
  3. 3. Notebook Nog niet opgelost
  4. 4. Times tables Nog niet opgelost
  5. 5. Voting count Nog niet opgelost
  6. 6. Fizz Buzz Nog niet opgelost
  7. 7. Find and replace Nog niet opgelost
  8. 8. Twelve days of Christmas Nog niet opgelost
  9. 9. Distribution of two dice Nog niet opgelost
Volgende reeks Assessment point: levels 01-06
Level 06: count controlled iterations and scope

2. Rainfall

Meld je aan om je oplossing in te dienen en feedback te krijgen.

# 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))