Skip to content

Instantly share code, notes, and snippets.

@Deshan555
Last active August 11, 2022 04:34
Show Gist options
  • Select an option

  • Save Deshan555/ab9e8388a0f64ff9fba4f5fcc8f48aec to your computer and use it in GitHub Desktop.

Select an option

Save Deshan555/ab9e8388a0f64ff9fba4f5fcc8f48aec 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…
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"
num_rainy_months = 0
data_sheet: list = rainfall_mi.split(", ")
for x in data_sheet:
conv = float(x)
if conv > 3.0:
num_rainy_months = num_rainy_months + 1
print(num_rainy_months)

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 > 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment