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.


techstudy.org

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

  1. num1 = float(input("Input first number: "))
  2. num2 = float(input("Input second number: "))
  3. num3 = float(input("Input third number: "))
  4. if num1 > num2:
  5. if num1 < num3:
  6. median = num1
  7. elif b > num3:
  8. median = num2
  9. else:
  10. median = num3
  11. else:
  12. if num1 > num3:
  13. median = num1
  14. elif num2 < num3:
  15. median = num2
  16. else:
  17. median = num3
  18.  
  19. print("The median is", median)
  20.  

Result

python language techstudy.org

     





Related Topics




Popular Posts