Tech Study

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

Introduction

Write a Python program to find the median among three given numbers. 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

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

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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more