Average of Array
EasyP3Coding
Return the average of the elements of arr as a floating-point number (the sum divided by the length, with no rounding).
Example 1
- Input
- arr = [1,2,3,4]
- Output
- 2.5
- Why
- 10 / 4 = 2.5
Example 2
- Input
- arr = [5]
- Output
- 5
Example 3
- Input
- arr = [1,2]
- Output
- 1.5
Constraints
- 1 <= arr.length <= 10^5
- -10^6 <= arr[i] <= 10^6
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.