Download Body Mass Index Program Python

Posted on

BMI calculator in Python. But overall, good job on writing your first program! Body mass index calculator in Swift. Develop a program that computes the body mass index (BMI) of an individual. Program should begin by reading a height and weight from the user. If you read the height.

Sorry about my previous question. The question I have to answer is this: Body Mass Index (BMI) is a good indicator of body fatness for most people. The formula for BMI is weight/ height2 where weight is in kilograms and height is in meters. Write a program that prompts for weight in pounds and height in inches, converts the values to metric, and then calculates and displays the BMI value. What I have so far is this: ' BMI Calculator 1.

Give More Feedback

See

Obtain weight in pounds and height in inches 2. Convert weight to kilograms and height to meters 3. Calculate BMI with the formula weight/height^2 ' #prompt user for input from keyboard weight= input ('How much do you weigh (in pounds)?'

See more on stackoverflow

) #this get's the person's weight in pounds weightinkg= weight/2.2 #this converts weight to kilograms height= input ('What is your height (in inches)?' ) #this gets the person's height in inches heightinmeter=height.2.54 #this converts height to meters bmi=weightinkg/(heightinmeters.2) #this calculates BMI print (BMI) My first step works, but that is the easy part. I know that in Python the equal sign assigns something, so I'm not sure if that is the problem, but I really do not know what to do. I am really sorry. When I run the program it says: TypeError: unsupported operand type(s) for /: 'str' and 'float' If anyone could give me any tips on what I am doing wrong, I would really appreciate it. And if not, thank you for your time. Thanks again.

First off, there was a typo: heightinmeter(S). For Python 2, a preceding float(.

Is not necessary, although I am sure it is good practice. ' BMI Calculator 1. Obtain weight in pounds and height in inches 2. Convert weight to kilograms and height to meters 3. Calculate BMI with the formula weight/height^2 ' #prompt user for input from keyboard weight= input ('How much do you weigh (in pounds)?' ) #this get's the person's weight in pounds weightinkg= weight/2.2 #this converts weight to kilograms height= input ('What is your height (in inches)?'

) #this gets the person's height in inches heightinmeter=height.2.54/100 #this converts height to centimeters bmi=weightinkg/(heightinmeter.2) #this calculates BMI print (bmi).

See more on stackoverflow

The program calculates a person's BMI from the weight and height supplied using the user's input. However, after I enter 'metric' or 'imperial' and press enter, the program closes. The first three print functions work fine and anything after doesn't appear subsequent to me pressing the enter button. How do I fix this? Print(' t t t BMI Calculator') print(' t t t By Abdinasir Hussein') print(' n Hello, this is a BMI Calculator!' ) input('Do you wish to enter metric units or imperial units: ') while input 'metric': height = float(input('Please enter your height input meters(decimals): ')) weight = int(input('Please enter your weight input kg: ')) bmi = weight/(height.height) if bmi 18.5 and bmi 25 and bmi 30: print('Your BMI is', bmi,'which means you are obese.' ) else: print('There is an error with your input') print('Please check you have entered whole numbers n' 'and decimals were asked.'

) while input 'imperial': height = int(input('Please enter your height input inputches(whole number): ')) weight = int(input('Please enter your weight input pounds(whole number): ')) bmi = (weight.703)/(height.height) if bmi 18.5 and bmi 25 and bmi 30: print('Your BMI is', bmi,'which means you are obese.' ) else: print('There is an error with your input') print('Please check you have entered whole numbers n' 'and decimals were asked.' ) input(' n nPlease press enter to exit.' ) I've now changed it, but how do I go about editing this block: input = input('Do you wish to enter metric units or imperial units: ') if input 'metric': height = float(input('Please enter your height input meters(decimals): ')) weight = int(input('Please enter your weight input kg: ')) bmi = weight/(height.height) if bmi 18.5 and bmi 25 and bmi 30: print('Your BMI is', bmi,'which means you are obese.' ) else: print('There is an error with you inputput') print('Please check you have entered whole numbers n' 'and decimals where asked.'