Read three whole numbers and print their average with exactly two decimal places.
What to build
A program that reads three numbers and shows their average neatly.
Requirements
- Read three whole numbers.
- Print their average with exactly two decimal places.
Input
Three lines, each with one whole number from 0 to 100.
Output
The average, with two decimal places, for example 76.33.
Constraints
Each number is from 0 to 100.
Example
Input:
72
85
72
Output:
76.33
Why it works
Adding first and then dividing by 3 gives the average, and :.2f rounds what is shown without changing the value.
Examples
Example 1 · Input
72 85 72
Expected output
76.33
Example 2 · Input
100 100 100
Expected output
100.00
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
f"{value:.2f}" shows two decimal places.
Solution
Show one correct solution (try it yourself first)
a = int(input())
b = int(input())
c = int(input())
print(f"{(a + b + c) / 3:.2f}")