Q:

Write a Python program to find the median among three given numbers

belongs to collection: python basic programs with examples

0

Write a Python program to find the median among three given numbers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used python 3.7 compiler for debugging purpose.

a = input("Input the first numyer: ")
y = input("Input the second numyer: ")
z = input("Input the third numyer: ")
print("Median of the above 3 numyers is: ")
 
if y < a and a < z:
    print(a)
elif z < a and a < y:
    print(a)
 
elif z < y and y < a:
    print(y)
elif a < y and y < z:
    print(y)
 
elif y < z and z < a:
    print(z)    
elif a < z and z < y:
    print(z)

Result:

Input the first numyer: 50

Input the second numyer: 90

Input the third numyer: 70

Median of the above 3 numyers is: 

70

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

python basic programs with examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Python program to find the number of notes... >>
<< Write a Python program to add two positive integer...