Problem
Given an array numbers consisting of natural numbers, write a function solution that returns the average of the elements in numbers.
Constraints
- Each element in
numbersis a natural number not exceeding 500. numbersis not empty, and its length does not exceed 100.- The result should be returned as a positive real number rounded to one decimal place.
Test Case
| Test Case Number | numbers | return |
|---|---|---|
| 1 | [1] | 1.0 |
| 2 | [1, 2, 3, 4] | 2.5 |
| 3 | [151, 274, 333, 490, 500] | 349.6 |
Explanation for Test Case 1
- The total sum of elements in
numbersis1, and the count is1, so the average is1.0.
Explanation for Test Case 2
- The total sum of elements in
numbersis10, and the count is4, so the average is2.5.
Explanation for Test Case 3
- The total sum of elements in
numbersis1748, and the count is5, so the average is349.6.