Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
The first line is n. The second line has n integers. Print their average, rounded to exactly two decimal places.
Averaging is sum divided by count — the everyday reduction behind every "mean" you will ever compute.
Input. Line 1: n. Line 2: n integers separated by spaces.
Output. The average with two decimals, e.g. 5.00.
Constraints
- 1 ≤ n ≤ 1000
Examples
Input
4 2 4 6 8
Output
5.00
Input
3 1 2 2
Output
1.67
Hint
- sum(nums) / n gives a float — use / not // so decimals survive.
- Format the result with f"{value:.2f}".
Show correct code
Peek only after you have tried. You can still Check your own version.
n = int(input())
nums = list(map(int, input().split()))
print(f"{sum(nums) / n:.2f}")
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.