Function Name: mean() Parameters: sample a list of integer values Return Value: None - Description: You are probably familiar with the arithmetic mean of a sample – the kind of mean where you sum the values of the sample (perhaps grades or test scores) and you divide by the number of values. It turns out there are several kinds of mean: arithmetic mean, geometric mean, harmonic mean, and plenty more! Your task is to write a function that computes arithmetic mean and the geometric mean of a sample. To compute the geometric mean of a sample, you first take product of all the values, and then you take the n-th root of the product, where n is the number of values you have (see the picture below). n x1 x2 • • xn Test Cases: >>> mean([1, 2, 3]) AM: 2.0 GM: 1.81712059283 >>> mean([4, 4, 2, 10, 13, 57, 68, 70, 99, 105]) AM: 43.2 GM: 20.2740243268

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

You have to make sure that all the variables you use in your solution are floats. (1.0 instead of 1 and 0.0 instead of 0) 

Function Name: mean()
Parameters:
sample a list of integer values
Return Value: None
-
Description: You are probably familiar with the arithmetic mean of a sample – the kind of mean where you
sum the values of the sample (perhaps grades or test scores) and you divide by the number of values. It turns
out there are several kinds of mean: arithmetic mean, geometric mean, harmonic mean, and plenty more!
Your task is to write a function that computes arithmetic mean and the geometric mean of a sample. To
compute the geometric mean of a sample, you first take product of all the values, and then you take the n-th
root of the product, where n is the number of values you have (see the picture below).
n
x1 x2
• •
xn
Test Cases:
>>> mean([1, 2, 3])
AM: 2.0
GM:
1.81712059283
>>> mean([4, 4, 2, 10, 13, 57, 68, 70, 99, 105])
AM: 43.2
GM: 20.2740243268
Transcribed Image Text:Function Name: mean() Parameters: sample a list of integer values Return Value: None - Description: You are probably familiar with the arithmetic mean of a sample – the kind of mean where you sum the values of the sample (perhaps grades or test scores) and you divide by the number of values. It turns out there are several kinds of mean: arithmetic mean, geometric mean, harmonic mean, and plenty more! Your task is to write a function that computes arithmetic mean and the geometric mean of a sample. To compute the geometric mean of a sample, you first take product of all the values, and then you take the n-th root of the product, where n is the number of values you have (see the picture below). n x1 x2 • • xn Test Cases: >>> mean([1, 2, 3]) AM: 2.0 GM: 1.81712059283 >>> mean([4, 4, 2, 10, 13, 57, 68, 70, 99, 105]) AM: 43.2 GM: 20.2740243268
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education