#Rainfall Data Python Project (Beginner Python programming)
1 messages · Page 1 of 1 (latest)
In this tutorial I show you how to create a function that returns the smallest number in a list
it’s the same thing… just look at the code within it
If I were to use those codes, my project will be marked a 0
ur not supposed to copy-paste it, just analyze what the code is doing and then apply it
@sour meadow I don’t know if this will actually run without errors, but this is at least the general idea of how you could do it.
lowest_rainfall = rainfall[0]
lowest_rainfall_days = [0]
for day in range(len(rainfall)):
if rainfall[day] < lowest_rainfall:
lowest_rainfall = rainfall[day]
lowest_rainfall_days = [day]
elif rainfall[day] == lowest_rainfall:
lowest_rainfall_days.append(day)
print(lowest_rainfall)
print(lowest_rainfall_days)
Are u able to use a dataframe for this assignment or will u be marked down for that aswell?
Probably not
Ah shoot
I was able to find the wettest days and the driest days
However, now it's just the matter of making it look properly.
We're about 80% done. I just need it to say, "Here are the driest days." print the driest days
which I need to loop through the array and print out which days have a rainfall that equal max_rain
but how
I would make a list instead, like max_rain_days = [1].
if log > max_rain, then you would make max_rain_days equal to [days]
elif log == max_rain, then you would append days to max_rain_days
then, to print, you can do
for day in max_rain_days:
print(f”Day {day}: {max_rain}”);