Advertisement
CorporalCompassion

Yay Python

Mar 22nd, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. def main():
  2.     print("Body Mass Index (BMI) Program")
  3.     print()
  4.     weight = float(input("Enter your weight in pounds: "))
  5.     while (weight < 50 or weight > 500):
  6.         print('ERROR: Please enter a value between 50 and 500')
  7.         weight = float(input('Please enter a valid weight:'))
  8.     height = float(input("Enter your height in inches: "))
  9.     while (height < 48 or height > 100):
  10.         print('ERROR: Please enter a value between 48 and 100')
  11.         weight = float(input('Please enter a valid height:'))
  12.     incalcBMI = calcBMI(weight, height)
  13.     displayResults(incalcBMI)
  14.    
  15. def calcBMI(weight, height):
  16.     bmi = (weight * 703)/(height * height)
  17.     print()
  18.     return bmi
  19.  
  20. def displayResults(bmi):
  21.     print("Your BMI is:",\
  22.           format(bmi, ",.2f"))
  23.     if bmi >= 18.5 and bmi < 25:
  24.         print("This person is: An optimal weight")
  25.     elif bmi >= 25:
  26.         print("This person is: Overweight")
  27.     elif bmi <= 18.5:
  28.         print("This person is: Underweight")
  29.  
  30. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement