-
Notifications
You must be signed in to change notification settings - Fork 0
/
rainfall.py
30 lines (22 loc) · 863 Bytes
/
rainfall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Rain fall program
# This program will let the user to enter the total rain fall for 12 months
# in to a list. Then the program should calculate the total rain fall for
# a year, the average monthly rainfall and the months that have the higher
# and lower amounts.
def main() :
num_list = []
total = 0
for i in range (1, 5):
print('Enter the rainfall for %d month :'%(i), end=" ")
rainfall = float(input())
num_list.append(rainfall)
for num in num_list:
total += num
ave = total / len(num_list)
print('Total rainfall for a year : %.2f' % (total))
print('The average is : %.2f' % (ave))
maxi = max(num_list)
mini = min(num_list)
print('The maximum rainfall for a year is : ', maxi)
print('The minimum rainfall for a year is : ', mini)
main()