Question: Problem 3. (Geometric and Harmonic Means) Write a program means.py that reads in positive real numbers from standard input and writes their geometric and harmonic

Problem 3. (Geometric and Harmonic Means) Write a program means.py that reads in positive real numbers from standard input and writes their geometric and harmonic means. The geometric mean of n positive numbers x1,x2,...,xn is (x1 x2 xn)1/n and their harmonic mean is n/(1/x1 + 1/x2 ++ 1/xn). Hint: for the geometric mean, consider taking logarithms to avoid overow; if y = (abc)1/d, then lny = (1/d)(lna + lnb + lnc) = x (say), and y = ex. $ python3 means.py 1.0 2.0 3.0 4.0 5.0 geometric mean = 2.605171, harmonic mean = 2.189781

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!