← Back to Functions
Question 353
Average Without Sum
Average Without Sum
Write def average_of(values: list[float]) -> float that returns the average of the numbers in the list, which always has at least one element, without using the built-ins sum or len: loop over the list once, adding each value to a running total and adding one to a counter, then return the total divided by the counter. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: a count on the first line, then that many decimal numbers one per line; the tests read them, build the list, pass it to your function and print the value it returns as Python prints a float.
Expected Output:
85.0= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Functions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.