Novice · Arithmetic · 19 of 264
Average of three
Read three whole numbers and print their average with exactly two decimals.
Input: three whole numbers, one per line. Output: the average, e.g. 4.33 Tip: f"{x:.2f}" shows x with two decimals.
Examples
Input
4 4 5
Output
4.33
Input
1 2 3
Output
2.00
Input
10 0 -4
Output
2.00
One more test checks other inputs when you press Check.
Stuck? The idea behind arithmetic
input() always gives text: turn it into a whole number with int() or a decimal with float() before doing sums.
+ - * / work as in maths; / always gives a decimal. // divides and drops the remainder, % gives the remainder, ** raises to a power.
a = int(input()) b = int(input()) print(a + b) print(a // b, a % b)
Watch for: "5" + "3" is "53", not 8: if a sum joins numbers together, an int() is missing.