#Rainfall Data Python Project (Beginner Python programming)

1 messages · Page 1 of 1 (latest)

sour meadow
#

Rainfall Data Python Project (Beginner Python programming)

swift vault
sour meadow
#

Doesn't help

#

It's using for, def which is forbidden to use

swift vault
sour meadow
#

If I were to use those codes, my project will be marked a 0

swift vault
#

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)
swift vault
sour meadow
#

Probably not

swift vault
#

Ah shoot

sour meadow
#

I was able to find the wettest days and the driest days

#

However, now it's just the matter of making it look properly.

sour meadow
#

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

swift vault
# sour meadow 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}”);