Tech Study

Python Program to Find Median of 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

Here are some more example of python program for your practice :

Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum.

Write a Python program that accepts a string and calculate the number of digits and letters

TaggedWrite a Python program to find the median of three values

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more