Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Given an array of numbers nums, compute the arithmetic mean (average) using NumPy.
Return the mean rounded to 2 decimal places.
| Argument | Type |
|---|---|
| nums | list |
| Return Name | Type |
|---|---|
| value | float |
where is the length of the list
List elements are numeric (e.g., int or float)
Must raise ValueError if the input list is empty
Must not use external libraries (pure Python only)
Maintain a running sum and a count while iterating through the list.
Avoid dividing by len(nums) if you want a single-pass solution that also validates elements as you go.
Use Python’s built-in round(value, 2) to enforce 2-decimal rounding at the end.