Task
Create a program that asks the user for 10 numbers (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statistics | |
a=float(input("Write the first number")) | |
b=float(input("Write the second number")) | |
c=float(input("Write the third number")) | |
d=float(input("Write the fourth number")) | |
e=float(input("Write the fifth number")) | |
f=float(input("Write the sixth number")) | |
g=float(input("Write the seventh number")) | |
h=float(input("Write the eighth number")) | |
i=float(input("Write the ninth number")) | |
j=float(input("Write the tenth number")) | |
list1 = [a, b, c, d, e, f, g, h, i, j] | |
print("The standard deviation value of the numbers you provide is", statistics.stdev(list1)) | |
print("The average deviation of the numbers you provide is", statistics.mean(list1)) | |
print("The total deviation of the numbers you provide is", sum(list1)) |
Learnings
- List: this variable allows you to store multiple variables (can be of different data type). The variables are enclosed in brackets “[]”.
- Tuple: this is like a list but tuples are enclosed in parentheses “()”and most can’t be updated. Once you store the values in a tuple, you can’t change them.
- Creation and use of Lists/Tuples: You just have to write inside brackets (for list) or parenthesis (for tuples) the variables you want to be part of it.