Program to compute the average of the numbers provided. Enter each number followed by . When...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Program to compute the average of the numbers provided. Enter each number followed by <enter>. When you are done, just hit <enter> in response to the prompt.. Enter a number: 10 Enter a number: 15 Enter a number: 5 Enter a number: 10 Enter a number: You entered 4 numbers. The average is 10.0. HINTS 1. When a user hits <enter> without typing any text, input () returns an empty string (called a null string). If checked as a boolean, a null string will be interpreted as False. A string containing characters will be interpreted as True. You can use this property to control a while loop. 2. As we gain knowledge, we also gain the ability to evaluate different solution methods. Here, you could keep a running total as the user enters each number OR you could accumulate the numbers in a list and process them after exiting the loop. You could accumulate the response strings through concatenation and convert that to a list using split() or you could accumulate the response strings in a list or you could convert the response strings to floats and append the floats to a list. Which results in the most readable code? What circumstances would prefer one solution over the other? Program to compute the average of the numbers provided. Enter each number followed by <enter>. When you are done, just hit <enter> in response to the prompt.. Enter a number: 10 Enter a number: 15 Enter a number: 5 Enter a number: 10 Enter a number: You entered 4 numbers. The average is 10.0. HINTS 1. When a user hits <enter> without typing any text, input () returns an empty string (called a null string). If checked as a boolean, a null string will be interpreted as False. A string containing characters will be interpreted as True. You can use this property to control a while loop. 2. As we gain knowledge, we also gain the ability to evaluate different solution methods. Here, you could keep a running total as the user enters each number OR you could accumulate the numbers in a list and process them after exiting the loop. You could accumulate the response strings through concatenation and convert that to a list using split() or you could accumulate the response strings in a list or you could convert the response strings to floats and append the floats to a list. Which results in the most readable code? What circumstances would prefer one solution over the other?
Expert Answer:
Answer rating: 100% (QA)
Answer initializing variables total 0 count 0 reading ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Location: Brazil Product: MacBook Air The Market Describe the market(s) in which the product is to be sold 1. Geographical region(s) 2. Forms of transportation and...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In Exercises evaluate the second derivative of the function at the given point. Use a computer algebra system to verify your result. (x) = cos x, (0, 1)
-
A parallel beam of Unpolarized light in air is incident at an angle of 54.5 (with respect to the normal) on a plane glass surface. The reflected beam is completely linearly polarized. (a) What is the...
-
Find the transfer function, G(s) = V o (s)/Vi(s), for each operational amplifier circuit shown in Figure P2.8. 110 k2 4 F (1ya 400 k2 4 F (a) 110 k2 HE 600 k2 4 F 400 k2 4 F 600 k2 (b) FIGURE P2.8...
-
A Map of All Americans! Visualization can often be an effective way to make sense of very large datasets. The Census Dot Map at http://demogra phics.coopercenter.org/DotMap/ displays the race and...
-
Kelly Foods has two plants and ships canned vegetables to customers in four cities. The cost of shipping one case from a plant to a customer is given in the following table. The plant in Akron has a...
-
Consider SELECT statements listed below. SELECT L_PARTKEY, L_TAX, COUNT(*) FROM LINEITEM GROUP BY L PARTKEY, L_TAX; SELECT O TOTALPRICE, COUNT(*) FROM ORDERS GROUP BY O TOTALPRICE; SELECT L_TAX,...
-
Consider again the CHB Inc. problem described in Problem 10. Suppose only a limted number of PPBs can be placed. CHB would like to place this limited number of PPBs in counties so that the allowable...
-
In contrast to older holiday lights that used incandescent bulbs with filaments (that always burned out), modern lights usually consist of light-emitting diodes (LEDs) that are constructed of...
-
Luzadis Company makes furniture using the latest automated technology. The company uses a job - order costing system and applies manufacturing overhead cost to products on the basis of machine -...
-
What happens if the default gateway of your host went down?
-
James Kettle disposed of an Antique clock on 23 March 2022 for $17,300. He had acquired the clock on 12 May 1988 for $8,600. Calculate the assessable net capital gain on disposal of the clock using:...
-
Diego Company manufactures one product that is sold for $ 7 5 per unit in two geographic regionsEast and West. The following information pertains to the companys first year of operations in which it...
-
In 2014, when Sherry was 56 years old with an additional life expectancy of 20 years, she purchased a single life annuity for $200,000 that was to pay her $15,000 per year for life starting in 2015....
-
On January 1, 2021, Polly Corporation acquired 85% of the voting common shares of Sunny Ltd. for $867,000. The shareholders' equity of Sunny on January 1, 2021 had a book value of $700,000. All of...
-
X-1 Find the domain of the function f(x) : x 1 2 - O (-00, -1) U (-1, ) O (-00, 1) U (1, ) O -00, -1) U (-1, 1) U (1, 0) O (- 1, 1)
-
Laura is a single taxpayer living in New Jersey with adjusted gross income for the 2012 tax year of $35,550. Laura's employer withheld $3,300 in state income tax from her salary. In April of 2012,...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
Sophie is a single taxpayer. For the first payroll period in October 2012, she is paid wages of $3,250 monthly. Sophie claims three allowances on her Form W-4. a. Use the percentage method to...
-
Consider heat transfer over a flat plate again but now include an additional term due to viscous heating. Show that the similarity method is applicable to this problem as well, and derive the...
-
For the similarity solution, what are the boundary conditions for the constant-wall-flux case? Show that a complete similarity does not exist for this case. Also show the condition for the case where...
-
Integral balances can also be used for heat transfer in a turbulent-flow boundary layer if a form for the velocity profile is assumed. A common form is the 1/7th-power law:...
Study smarter with the SolutionInn App