By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,156 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,156 IT Pros & Developers. It's quick & easy.

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

P: 2
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 :)

Expand|Select|Wrap|Line Numbers
  1.  
  2. # This program calculates a person's Body Mass Index
  3.  
  4. def main():
  5.     intro()
  6.     weight = input(int('What is your weight in pounds? ')
  7.     height = input(float('What is your height in inches? ')
  8.     print('Your BMI or Body Mass Index is: ')
  9.     bmi(weight, height)
  10.  
  11. def intro():
  12.     print('This program calculates your Body Mass Index')
  13.     print('which helps you determine if you are at a healthy weight')
  14.     print('Underweight is below 18.5')
  15.     print('Healthy weight is 18.5 to 24.9')
  16.     print('Overweight is 25 to 29.9')
  17.     print('Obese is above 30')
  18.  
  19. def bmi(weight, height):
  20.     bmi = weight * 703 / height**2
  21.     print(bmi)
  22.  
  23. main()
  24.  
  25.  
Feb 16 '14 #1

✓ answered by bvdet

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.

Share this Question
Share on Google+
2 Replies


bvdet
Expert Mod 2.5K+
P: 2,851
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.
Feb 16 '14 #2

P: 2
Thank you so much! This helps me out!! I knew I was in the right direction. :)
Feb 16 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.