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.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. a = input("Input the first numyer: ")
  2. y = input("Input the second numyer: ")
  3. z = input("Input the third numyer: ")
  4. print("Median of the above 3 numyers is: ")
  5.  
  6. if y < a and a < z:
  7. print(a)
  8. elif z < a and a < y:
  9. print(a)
  10.  
  11. elif z < y and y < a:
  12. print(y)
  13. elif a < y and y < z:
  14. print(y)
  15.  
  16. elif y < z and z < a:
  17. print(z)
  18. elif a < z and z < y:
  19. print(z)

Result

python language techstudy.org

     





Related Topics




Popular Posts