Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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 "Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started