Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that allows the user to enter the total rainfall for each of 12 months into a list. The program should calculate and

Write a program that allows the user to enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest rainfall amounts.

Data:

January 7.9 inches

February 10.1 inches

March 3.4 inches

April 6.7 inches

May 8.9 inches

June 9.4 inches

July 5.9 inches

August 4.1 inches

September 3.7 inches

October 5.1 inches

November 7.2 inches

December 8.3 inches

Code is not working.

Rainfall = list() # Defining the rainfall as list Month = ['January','February','March','April','May','June','July','August','September','October','November','December']; for i in Month: # For each value in month, append rainfall in Rainfall list print 'Enter Rain fall in inches for the month:',i Rainfall.append(float(raw_input()))

T = sum(Rainfall) # sum function calculates the total of rainfall print "Total rainfall in the year is : ",T A= T/12 print "Average rainfall in the Month is : ",A

for i in range(12): if(Rainfall[i]==max(Rainfall)): # max return higest rainfall value print Month[i],"Has the highest rainfall amount :" , Rainfall[i],"inches" if(Rainfall[i]==min(Rainfall)): # min returns lowest rainfall value print Month[i],"Has the Lowest rainfall amount :" , Rainfall[i],"inches"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions