Whole-number average
Inputs
values is a list of 1 to 12 whole numbers, each from 0 to 100.
Your tasks
- Create a number
totaland use a loop to add every number invaluesto it. - Divide
totalby the number of values and round the result down to a whole number. - Complete
averageFloorso it returns the rounded-down average. Return it, do not print it.
Example
With values = [4, 9, 7], averageFloor returns 6.
Rules
valuesalways has at least one number.
Test data
TEST DATA 1: values is [4, 9, 7]
TEST DATA 2: values is [10]
Practice focus
One pass over a list to add, count, find the biggest and the smallest. Scanning an array once and keeping a running answer is the backbone of linear-time solutions.