Write a program that has global variables avg_int and avg_float. Write a function that will take...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that has global variables "avg_int" and "avg_float". Write a function that will take an arbitrary number of ints/floats as arguments. In the function, you will need to process all of the values passed into the function, first determining if the number is a float or an int. You should keep track of the "total" and "number" of ints and floats so that you can calculate the average int and average float (this can be done with a list, with is "arguably" easier). Once you have processed all of the values from the argument list and calculated the averages, set the global variables for avg_int and avg_float. Have the function return the value "0" if the argument list was empty, "1" if the numbers were all ints, a "2" if they were all floats, and a "3" if it was a mix of ints and floats. Once you have finished a call to the function, print out the appropriate information, such as: • "The list contained ints, and the average is 43.2" • "The list contained a mix of ints and floats. The average of the ints was 43.2, and the average of the floats was 23.2" • "There were no values in the list." Note: the Python function used to determine if a number is a float or an int is "isinstance()". Part of this assignment is you looking up the documentation for this function and determining how it works. Write a program that has global variables "avg_int" and "avg_float". Write a function that will take an arbitrary number of ints/floats as arguments. In the function, you will need to process all of the values passed into the function, first determining if the number is a float or an int. You should keep track of the "total" and "number" of ints and floats so that you can calculate the average int and average float (this can be done with a list, with is "arguably" easier). Once you have processed all of the values from the argument list and calculated the averages, set the global variables for avg_int and avg_float. Have the function return the value "0" if the argument list was empty, "1" if the numbers were all ints, a "2" if they were all floats, and a "3" if it was a mix of ints and floats. Once you have finished a call to the function, print out the appropriate information, such as: • "The list contained ints, and the average is 43.2" • "The list contained a mix of ints and floats. The average of the ints was 43.2, and the average of the floats was 23.2" • "There were no values in the list." Note: the Python function used to determine if a number is a float or an int is "isinstance()". Part of this assignment is you looking up the documentation for this function and determining how it works.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these operating system questions
-
You work for a company that makes cell phones and have been made project manager for the design of a new cell phone. Your supervisors have already scoped the project, so you have a list showing the...
-
You work for a company that makes electrical kitchen appliances. For the upcoming annual corporate strategy meeting, the members of the strategy council have requested you to make the case for a...
-
You work for a company that makes small photoelectric modules that are sold to other companies to be assembled into large solar power arrays. The graph on the next slide shows cost and revenue...
-
Suppose, in the New Monetarist model, that there is deficient financial liquidity. If the fiscal authority were to engineer a tax cut, financed by an increase in the quantity of government debt, with...
-
Following are extracts from the financial statements of Elisa County for the year ended December 31, 2013. The funds shown are the governmental operating funds; Capital Projects Funds are omit-ted....
-
Abernathy Corporation was organized on January 1, 2015. It is authorized to issue 10,000 shares of 8%, \($50\) par value preference shares, and 500,000 shares of no-par ordinary shares with a stated...
-
Petitioner Salman was indicted for federal securities-fraud crimes for trading on inside information he received from a friend and relative-by-marriage, Michael Kara, who, in turn, had received the...
-
(EPS: Simple Capital Structure) On January 1, 2010, Bailey Industries had stock outstanding as follows. 6% Cumulative preferred stock, $100 par value, issued and outstanding 10,000 shares $1,000,000...
-
Does the City Project Meet the Pareto Efficiency Criterion? Stanley Ryan, Your Supervisor Read the following scenario and then answer the Problem Demonstration Questions below. The allocation of...
-
Using the Internet, find two examples of advertisements for sports products that use indirect objectives and two examples of advertisements that use direct objectives.
-
Suppose there are two functions implemented in RISC-V assembly: F1 and F2. Function F1 uses function F2 to generate its results. Function F1 uses registers t0, t1, t2, s0, s1, and function F2 uses...
-
What is the hockey stick phenomenon in relation to the use of incentives to increase supply chain surplus? What steps can be taken to address it?
-
As the standard deviation of forecast error increases, expected overstock increases and expected understock increases. expected overstock increases and expected understock decreases. expected...
-
Consider a manufacturer selling DVDs to a retailer for $6 per DVD. The production cost of each DVD is $1 and the retailer prices each DVD at $10. Retail demand for DVDs is normally distributed, with...
-
Design a tailored supplier portfolio.
-
What revenue management opportunities are available to a supermarket? How can it take advantage of them?
-
What is the balance of the Investment in Subsidiary account at the end of the year using the Cost Method and the Equity Method? Investment in Subsidiary $200,000 Income share of subsidiaries $200,000...
-
Use integration by parts to evaluate the following. Check your answer by taking the derivative. x2e-xdx
-
Reread the Country Focus feature on outsourcing service jobs. Is there a difference between the transference of high-paying white collar jobs, such as computer programming and accounting, to...
-
Discuss how the need for control over foreign operations varies with firms strategies and core competencies. What are the implications for the choice of entry mode?
-
What are the potential costs of adopting a free trade regime? Do you think governments should do anything to reduce these costs? What?
-
A certain radar has the following specifications: pulse width \(\tau^{\prime}=1 \mu\) s, antenna beam width \(\Omega=1.5^{\circ}\), and wavelength \(\lambda=3 \mathrm{~cm}\). The radar antenna is...
-
One implementation of a single delay line canceler with feedback is shown below. (a) What is the transfer function, \(H(z)\) ? (b) If the clutter power spectrum is \(W(f)=w_{0} \exp \left(-f^{2} / 2...
-
(a) Derive an expression for the impulse response of a single delay line canceler. (b) Repeat for a double delay line canceler.
Study smarter with the SolutionInn App