I can't get my simple Body Mass Index calculator to work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hh5280
    New Member
    • Feb 2014
    • 2

    I can't get my simple Body Mass Index calculator to work

    I am very new to python and I just want to write a simple program that calculates BMI using a simple function with arguments...It just tells me that my first "height" syntax is wrong. Help please :)

    Code:
    # This program calculates a person's Body Mass Index
    
    def main():
        intro()
        weight = input(int('What is your weight in pounds? ')
        height = input(float('What is your height in inches? ')
        print('Your BMI or Body Mass Index is: ')
        bmi(weight, height)
    
    def intro():
        print('This program calculates your Body Mass Index')
        print('which helps you determine if you are at a healthy weight')
        print('Underweight is below 18.5')
        print('Healthy weight is 18.5 to 24.9')
        print('Overweight is 25 to 29.9')
        print('Obese is above 30')
    
    def bmi(weight, height):
        bmi = weight * 703 / height**2
        print(bmi)
    
    main()
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    You are missing a closing parenthesis on lines 6 and 7. After adding the parentheses, the script will fail on the int and float calls. Move those calls outside of the input argument. I also suggest naming the bmi function to something like bmi_calc to avoid confusion with the local variable bmi used inside the function scope.

    Comment

    • hh5280
      New Member
      • Feb 2014
      • 2

      #3
      Thank you so much! This helps me out!! I knew I was in the right direction. :)

      Comment

      Working...