Design a program that lets the user enter the total rainfall for each of 12 months into
Fantastic news! We've Found the answer you've been seeking!
Question:
Design a program that lets the user 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 amounts.
Transcribed Image Text:
in in WNHO 10 000 UTA W N P P P P P P P P P P 1 def main (): #Define list of months 3 months = [0] * 12 4 name_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] #Function for total number of months 5 8 total = 0. 9 for num in months: 10 total + num 11 return total 12 #amount of rain in each month 13 for index in range (12): 14 print 'Enter the amount of rain in', 15 months [index] input (name_months [index] + ': 16 print 'The total is', total (months), 17 #average 'mm. ' 18 avarage 6 NNNNNNNNNN 7 def total (months): UI total (months) / 12.0 19 print 'The avarage rainfall is', avarage, #firstly make an unsorted copy m_copy months [0] #Sorting list months.sort () months [0] 6000 20 684 WNHO 21 w w w w w 22 23 24 lowest 25 print 'Lowest is', lowest, 'in', 26 #we are going to make a list of the month names that = lowset 27 lows = [] 28 for i in range (12): 29 if m_copy[i] == lowest: 30 31 32 33 34 35 36 37 'mm. ' 38 lows.append( name_months[i]) for i in range (len (lows)) : print lows [1], if i 26 #we are going to make a list of the month names that = lowset 27 lows = [] for i in range (12): if m_copy[i] == lowest: 28 29 30 31 32 33 34 35 36 37 38 39 lows.append( name_months[i]) for i in range (len (lows)) : print lows [i], if i < len(lows) -1: print 'and', print highest = months [11] print 'Highest is', highest, 'in', #we are going to make a list of the month names that = highest highs = [] for i in range (12): if m_copy[i] == highest: 40 41 highs.append( name_months[i]) 42 for i in range (len (highs)) : 43 print highs[i], 44 if i < len(highs)-1: print 'and', 45 46 47 print main () in in WNHO 10 000 UTA W N P P P P P P P P P P 1 def main (): #Define list of months 3 months = [0] * 12 4 name_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] #Function for total number of months 5 8 total = 0. 9 for num in months: 10 total + num 11 return total 12 #amount of rain in each month 13 for index in range (12): 14 print 'Enter the amount of rain in', 15 months [index] input (name_months [index] + ': 16 print 'The total is', total (months), 17 #average 'mm. ' 18 avarage 6 NNNNNNNNNN 7 def total (months): UI total (months) / 12.0 19 print 'The avarage rainfall is', avarage, #firstly make an unsorted copy m_copy months [0] #Sorting list months.sort () months [0] 6000 20 684 WNHO 21 w w w w w 22 23 24 lowest 25 print 'Lowest is', lowest, 'in', 26 #we are going to make a list of the month names that = lowset 27 lows = [] 28 for i in range (12): 29 if m_copy[i] == lowest: 30 31 32 33 34 35 36 37 'mm. ' 38 lows.append( name_months[i]) for i in range (len (lows)) : print lows [1], if i 26 #we are going to make a list of the month names that = lowset 27 lows = [] for i in range (12): if m_copy[i] == lowest: 28 29 30 31 32 33 34 35 36 37 38 39 lows.append( name_months[i]) for i in range (len (lows)) : print lows [i], if i < len(lows) -1: print 'and', print highest = months [11] print 'Highest is', highest, 'in', #we are going to make a list of the month names that = highest highs = [] for i in range (12): if m_copy[i] == highest: 40 41 highs.append( name_months[i]) 42 for i in range (len (highs)) : 43 print highs[i], 44 if i < len(highs)-1: print 'and', 45 46 47 print main ()
Expert Answer:
Answer rating: 100% (QA)
As you have not mentioned the preferred programming language I am going to solve this problem in C h... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an...
-
Write a program that lets the user enter numbers from a graphical user interface and displays them in a text area, as shown in Figure 20.17a. Use a linked list to store the numbers. Do not store...
-
Listing 16.4, ComboBoxDemo.java, gives a program that lets the user view a country?s flag image and description by selecting the country from a combo box. The description is a string coded in the...
-
If the appropriate discount rate for the following cash flows is 7.13 percent per year, what is the present value of the cash flows? Year Cash Flow 1 ......................$1,400 2...
-
Find the lengths of each of the curves in Problem 35. You will first have to set up the appropriate integral and then use a computer to evaluate it. In problem 35 (a) x = 3 cos t, y = 3 sin t, 0 t ...
-
n vehicles occupy squares (1, 1) through (n, 1) (i.e., the bottom row) of an n n grid. The vehicles must be moved to the top row but in reverse order; so the vehicle i that starts in (i, 1) must end...
-
It looks to me that you have devoted everything to this company and they have treated you badly. Is that right?
-
Wild Expansion Co. acquired the following assets in exchange for various nonmonetary assets. 2011 Mar. 15 Acquired from another company a large lathe in exchange for three small lathes. The small...
-
Put the argument from the following passage into standard form and construct an argument map diagram. There is no need to include unstated premises (assumptions) in your answer. Australia should not...
-
a. Each of the following figures shows a person (not to scale) located on Earth at either 40?N or 40?S latitude Rank the figures based on how much time the person spends in day period. from most to...
-
Access the websites of a computer manufacturer such as gateway, dell, lenovo, sony, or toshiba. Consider the costs related to sales, production, and distribution of a laptop computer, both online and...
-
A man purchased a car with a cash price of P350,000. He was able to negotiate with the seller to allow him to pay only a down-payment of 20% and the balance payable in equal 48 end of the month...
-
What is the correct CPT code for a total thyroidectomy to remove thyroid cancer removal of all lymph nodes, along with spinal accessory nerve jugular vein and spiral clam mastoid muscles are...
-
What is the CPT code for thyroid lobectomy, right thyroid dissection is was divided from the left thyroid lobe, right thyroid lobe was completely removed from the trachea and surrounding tissues
-
Hajduk Limited has finalised the planning of a project that requires an investment of $112 million. In considering its financing options, Hajduk Limited can access debt finance at an incremental...
-
(6 points) What are the advantages and disadvantages of each of the following database applicati algorithms? Algorithm 1 Start a database transaction Get user choice While (user chooses not to exit)...
-
The probability that a concrete beam fails in compression test is 0.03. A sample of 100 beams is tested. a. What is the probability that at least four will fail in compression test?
-
How do the principles of (a) Physical controls and (b) Documentation controls apply to cash disbursements?
-
Suppose you put $10,000 into a CD with an annual percentage yield of 5.75%. After one month, the CD is worth? 10000 + 10000 * 5.75 / 1200 = 10047.92 After two months, the CD is worth? 10047.91 +...
-
Add the following method in the BST class that returns an iterator for traversing the elements in a BST in preorder. /** Returns an iterator for traversing the elements in preorder */...
-
Listing 6.8 implements the hex2Dec(String hexString) method, which converts a hex string into a decimal number. Implement the hex2Dec method to throw a NumberFormatException if the string is not a...
-
A university published the following distribution of students enrolled in the various colleges: Construct a bar chart of these data. College Enrollment College Enrollment Agriculture 1250 Liberal...
-
On ten days, a bank had 18, 15, 13, 12, 8, 3, 7, 14, 16, and 3 bad checks. Find the mean, median, variance, and standard deviation of the number of bad checks.
-
Calculate the mean and standard deviation of the following sample: -1, 4, 5, 0.
Study smarter with the SolutionInn App