Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 5 - Loops - Programming Exercises - Page 167: 5.46

Answer

code

Work Step by Step

# 5.46 (Statistics: compute mean and standard deviation) In business applications, you # are often asked to compute the mean and standard deviation of data. The mean is # simply the average of the numbers. The standard deviation is a statistic that tells # you how tightly all the various data are clustered around the mean in a set of data. # For example, what is the average age of the students in a class? How close are the # ages? If all the students are the same age, the deviation is 0. Write a program that # prompts the user to enter ten numbers, and displays the mean and standard deviations # of these numbers using the following formula: import math COUNT = 10 sum = 0 squareSum = 0 print("Enter ten numbers: ", end='') for i in range(COUNT): n = eval(input()) sum += n squareSum += n * n mean = sum / COUNT dev = math.sqrt((squareSum - sum * sum / COUNT) / (COUNT - 1)) print("The mean is", mean) print("The standard deviation is", dev)
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.