473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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.

2 1599
bvdet
2,851 Expert Mod 2GB
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
hh5280
2
Thank you so much! This helps me out!! I knew I was in the right direction. :)
Feb 16 '14 #3

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

Similar topics

3
by: Raphael Gluck | last post by:
Hi Everyone Just a simple question If i have more than one Javascript in the head tag, and both have a body Onload how do i write the opening body tag? do i enter two Onloads? This didnt work for...
7
by: J. Hall | last post by:
Hi dudes, Got a simple webpage, with three numeric text input boxes, the idea being that the user is asked to insert percentages of their business around the world... UK, Europe, Other ...
25
by: MeNotHome | last post by:
I am automating the navigation of a website. When I reach the end, it changes to xml. So my axwebbrowser1 has a bunch of xml data in it. So here is what I am trying to do Dim xmlText As...
5
by: sam | last post by:
Hi all, I am using documnet.body.scroll to disable the window scroll bar. This works in IE only and not other browsers. Can any one tell me if there is any such method which is cross browser...
2
by: boomer | last post by:
Having trouble programming for body mass index. Entering 180 lbs, 72 " ht
8
by: Jim Florence | last post by:
Hi, I've just add a couple of dropdowns to my ASP form, set up a sqldatasource and bound to the dropdown and it all works great. I want the first item of the dropdown to be blank soa fter...
0
by: Grzegorz Smith | last post by:
Hi All. I 'm learning ZSI to use SOAP and I desperately need help. I'm working on example from tutorial -(examples/server/send_response/ simple/wsdl/). Here are my wsdl files...
9
by: den | last post by:
if I have: string=/AAA/B/file.jpg; if I want change first slash, I writeo: var regexp = /\//; var_2 = stringa.replace(regexp, "zzz"); ok work and I have: zzzAAA/B/file.jpg;
4
by: themadjester | last post by:
Simple newb question here. Ok, so I am making a simple site. I wrote some HTML and made a CSS for it. Now, I know the point of the style sheets is to save me work re-doing all of the styles for...
3
by: ukfusion | last post by:
Im trying to get an image upload script to work within a session file.....i can get it to work on a single page without any other script....but i need to have the image upload facility built into a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.