Skip to content

Latest commit

 

History

History
38 lines (21 loc) · 822 Bytes

File metadata and controls

38 lines (21 loc) · 822 Bytes

Unit 4 Practice

Exercise 2 - Sum, Mean, Mode

Use a loop to create a list of 10 random numbers between 1 and 10.

2.1

Loop through the list of numbers and calculate the sum.

numbers: 1, 4, 6, 4, 6, 4, 5, 9
sum: 39

2.2

Loop through the list of numbers and calculate the mean (average).

numbers: 1, 4, 6, 4, 6, 4, 5, 9
mean: 4.875

2.3

Have your loop generate a list of 20 numbers instead.

Loop through the list of numbers and calculate the mode.

numbers: [4, 2, 7, 7, 5, 2, 6, 7, 8, 3, 7, 8, 5, 10, 8, 8, 9, 2, 6, 9]

mode: 8
The number 8 appears 4 times.

Exercise 2 solution