Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help writing a python BMI calc
    primarykey
    data
    text
    <p>I am new to python and and currently learning to use functions properly.</p> <p>I have been tasked with making a bmi calculator using python for my homework. This bmi calculator must give the option of whether to use metric or imperial units. based on this option it will then ask for your weight and height in the respectable unit type. This is where the problem stats - no matter what i input it still uses metric units and just seems to ignore my if/elif/else statments. so this is the first problem and i cant understand where i have gone wrong here.</p> <p>after that problem is solved, the bmi that it calculates needs to be put into a category and then the program should tell you which category your bmi fits into, this part doesn't even work for the metric bmi it just says:</p> <pre><code> """this is the error i keep getting, the actual code for the program is below""" traceback (most recent call last): File "C:/Python33/bmi calculator 2 2 2 2.py", line 54, in &lt;module&gt; catagory(bmi) File "C:/Python33/bmi calculator 2 2 2 2.py", line 45, in catagory if bmi &lt;18.5: TypeError: unorderable types: tuple() &lt; float() """this is a bmi calculator that works in both imperial and metric units and can tell your bmi category""" bmi = () metric = ("metric") Metric = ("Metric") imperial = ("imperial") Imperial = ("Imperial") MetricBMI = () ImperialBMI = () answer = input (" Do you want to work out you BMI using Metric or Imperial units?") def BMI(): metric = ("metric") Metric = ("Metric") imperial = ("imperial") Imperial = ("Imperial") if answer.lower() == metric: print("You have chose to calculate your bmi in metric units") Weight_kg = float(input("What is your weight in kilograms (kg)")) Height_m = float(input("What is your height in meters (m)?")) bmi = Weight_kg/Height_m/Height_m print("Your BMI is " + str(bmi)) elif answer.lower() == imperial: print ("You have chosen to calculate your bmi in imperial units") Weight_lbs = float(input("What is your weight in pounds (lbs)?")) Height_inches = float(input("What is your height in inches??")) bmi = Weight_lbs*703/Height_inches/Height_inches print ("Your BMI is " + str(bmi)) else: print ("please restart and enter either 'imperial' or 'metric'") BMI() def catagory(bmi): if bmi &lt;18.5: return ("You are underweight") elif bmi &gt;=18.5 and bmi &lt;25: return ("You are normal weight") elif bmi &gt;= 25 and bmi &lt;30: return ("you are overweight") elif bmi &gt;=30: return ("you are obese") catagory(bmi) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload