Average of Three Numbers
Programming Basics · Python
TASK
Problem
Given three numbers `a`, `b`, `c`, print their arithmetic mean.
EXAMPLE
Example
3 6 9
6.0
LIMITS
Constraints
All floating-point inputs are finite and have absolute value at most 10^9.
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `split()` separates one input line into individual values using spaces. `map()` applies the specified conversion to each input value. The `+` operator adds numbers. The `/` operator performs regular division and may return a decimal number. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** The `/` operator performs true division and returns a floating-point value in Python. This matters for averages, percentages, and formulas whose result may be fractional. The expression `(a + b + c) / 3` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Add the values and divide the sum by 3.']
ANSWER
Solution
+
a, b, c = map(float, input().split()) result = (a + b + c) / 3 print(result)