Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for this while, try and except code I need to not only get the average but also the number of times the floating point value

for this while, try and except code I need to not only get the average but also the number of times the floating point value was entered via len, the sum, sort the list of numbers and find the minimum and maximum. I was able to do this in a for loop but can't seem to include this in a while, try, and except without error. Basically, how do I merge the concepts from the for loop below into the while, try, and except code. I'm getting an error: TypeError: object of type 'float' has no len() just when I attempt to get the len.

Here is the for loop that I can't use b/c I need an while, try and exception :

image text in transcribed

_____________________________________________________________________________________________________________________________________

Here is the beginning of the while, try, and except which I need the length, sum, min and max concepts merged into:

total = 0.0 count = 0 value= 0.0

while value is not None:

try: value = float(input('Enter a floating point value :')) total += value count += 1 except: avg = total / count print('Average is ' + str(avg)) value =None

1 int (input ("Please enter the amount of numbers to input for n finding their average 3 numbers for i in range (0,n): num int(input ("Enter a floating point value numbers .append (num) avg sum (numbers) 10 print ("you entered values". format (len (numbers))) 11 print "Total of the entered numbers sum (numbers)) 12 print ("Average of the entered numbers round (avg,2)) 13 numbers. sort 14 print "The numbers you entered in sorted order: numbers) 15 print ("The minimum number you entered min (numbers 16 print ("The maximum number you entered max numbers 17

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

More Books

Students also viewed these Databases questions