Question: I'm asked to write a function that calculates the arithmetic mean, root mean square, harmonic mean, and geometric mean of a set of numbers imputed

I'm asked to write a function that calculates the arithmetic mean, root mean square, harmonic mean, and geometric mean of a set of numbers imputed by the user. I think I have the right formulas but keep getting the same error message (see pictures below). Any help would be much appreciated.I'm asked to write a function that calculates the arithmetic mean, rootmean square, harmonic mean, and geometric mean of a set of numbers

import math #Calculates the arithmetic mean, rms average, harmonic mean, and geometric mean #of a set of numbers: def mean() : num = int(input('Enter the number of values: ')). total = 0 product = 1 for i in range (num): numbers = eval(input('Enter value: ')) total = total + numbers a = 1+1 product *= a geomean = product** (1um) print ("the geometric mean is:", geomean) avg = totalum print ("The arithmetic mean is", avg) harmonic mean = num* (1/(sum (1umbers))) print ("The harmonic mean is:", harmonic_mean) rms average = math.sqrt ((sum (total**2)) um) print ("The RMS Average is:", rms_average) >>> mean() Enter the number of values: 4 Enter value: 10 Enter value: 5 Enter value: 2 Enter value: 5 the geometric mean is: 2.213363839400643 The arithmetic mean is 5.5 Traceback (most recent call last): File "", line 1, in mean() File "C:/Users/benno/Desktop/Computer Science/Lecture/mean.py", line 30, in me an harmonic mean = num* (1/ (sum (1umbers))) TypeError: 'float' object is not iterable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!