Created
February 19, 2020 18:33
-
-
Save mayankdawar/98c3fb71b5230cf3a21c1d2f9eff968c to your computer and use it in GitHub Desktop.
rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) with every month separated by a comma. Write code to compute the number of months that have more than 3 inches of rainfall. Store the result in the variable num_rainy_months. In other words, count the number of items with values…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rainfall_mi = "1.65, 1.46, 2.05, 3.03, 3.35, 3.46, 2.83, 3.23, 3.5, 2.52, 2.8, 1.85" | |
months = rainfall_mi.split(",") | |
count = 0 | |
for i in months: | |
if float(i) > 3.0: | |
count += 1 | |
num_rainy_months = count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment