Write a Python program to find the median of three values

Introduction

Write a Python program to find the median of three values.

I have used python 3.7 compiler for debugging purpose.

num1 = float(input("Input first number: "))
num2 = float(input("Input second number: "))
num3 = float(input("Input third number: "))
if num1 > num2:
    if num1 < num3:
        median = num1
    elif b > num3:
        median = num2
    else:
        median = num3
else:
    if num1 > num3:
        median = num1
    elif num2 < num3:
        median = num2
    else:
        median = num3
 
print("The median is", median)

Result

Write a Python program to find the median of three values
Write a Python program to find the median of three values

Leave a Comment