Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Write a program that has global variables avg_int and avg_float. Write a function that will take an arbitrary number of i

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.

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

Python code for the gi... 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

Global Business Today

Authors: Charles W. L. Hill

5th Edition

978-0073210544, 0073210544

More Books

Students also viewed these Operating System questions