Answered step by step
Verified Expert Solution
Link Copied!

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.image text in transcribedimage text in transcribed

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

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Develop successful mentoring programs. page 418

Answered: 1 week ago

Question

=+ Of the HR issues mentioned in the case,

Answered: 1 week ago