IDLE
.
2020-11-01 0 2020-11-02 1 2020-11-03 0 ...
def average_rain(file):
for
loop to get the rain for each date
def max_rain_date(file):
for
loop
and get the date and rainfall from each line
FILENAME = "rainfall.txt" file = open(FILENAME, "r") average = average_rain(file) print(average) file.close() file = open(FILENAME, "r") max_rain_date(file) file = open(FILENAME, "r") max_rain, max_date = max_rain_date(file) print(max_rain, max_date)
1.23 6 2020-11-07
pass
. pass
from
average_rain. print
statement from
average_rain. for
loop that prints every line
in the file. print
statement. print
statement. print
statement. round
is run with two arguments, the second
argument specifies that number of decimal places. pass
statement from
max_rain_date. print
statement. for
loop that prints every line in
the file. print
statement. print
statement. if
statement that will run in the
value of rain
is greater than max_rain. if
statement print the value of
rain. print
statement. print
statement. for
loop return both
max_rain and
max_date. 1.23 6 2020-11-07
cd it116/hw/hw9
./hw9.py
1.23 6 2020-11-07
Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.