Python bootcamp · Lab 49

Median of three

easyLists10 minLesson: Lists

Read the question, write Python on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read three integers and print the median (the middle value when sorted).

Input. One line: three integers.

Output. The middle value.

Examples

Example 1
Input
3 1 2
Output
2
Example 2
Input
9 9 1
Output
9
Hint
  1. sorted([a, b, c])[1] is the median.
Show correct code

Peek only after you have tried. You can still Check your own version.

a, b, c = map(int, input().split())
print(sorted([a, b, c])[1])
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.