Menu Close

Median of Three

Write a function that takes three numbers as parameters, and returns the median value of those parameters as its result. Include a main program that reads three values from the user and displays their median.

Hint: The median value is the middle of the three values when they are sorted into ascending order. It can be found using if statements, or with a little bit of mathematical creativity

Refer sample input and output for formatting specification.

def median(a,b,c):
  d=[a,b,c]
  d.sort()
  print(d[1])
a=int(input())
b=int(input())
c=int(input())
median(a,b,c)

Input_1:
5
2
10

Output:
5


Input_2:
50
10
100

Output:
50


Morae Q!