Function for calculating the arithmetic mean
Python
Easy
functions
Task «Function for calculating the arithmetic mean»
Write a function `average` that takes a list of numbers and returns their arithmetic mean. If the list is empty, the function should return 0. The function must not use the built-in `sum` and `len` functions. Input data is passed via stdin: first an integer `n` — the number of numbers, then `n` integers. Output the result with an accuracy of two decimal places.
Input Format
The first line contains an integer n (0 ≤ n ≤ 100). The second line contains n integers separated by spaces.
Output Format
One number — the arithmetic mean, rounded to two decimal places.
Examples
Example 1
INPUT
2
Laptop 1200.50 1
Mouse 25.00 2
card
pickup
OUTPUT
1079.78
Example 2
INPUT
1
Book 15.99 3
cash
courier
OUTPUT
55.17
main.py