TypeError: unsupported operand type(s) für &: 'float' und 'float'

Schrieb ich dieses einfache Programm zum berechnen des BMI. Aber ich bin nicht in der Lage, um ihn auszuführen, abgeschlossen. Unten ist mein Programm,

PROGRAMM

h = input("Please Enter your height in meters:")
q = raw_input("Do you want to enter your weight in kg or lbs?")

if q=="kg":
         w1 = input("Please Enter your weight in kgs:")
         bmi1 = w1/(h*h) 
         print "Your BMI is", bmi1

         if bmi1 <= 18.5: 
                        print "Your are underweight."
         if bmi1 > 18.5 & bmi1 < 24.9: 
                                     print "Your weight is normal."
         if bmi1 > 25 & bmi1 < 29.9: 
                                   print "Your are overweight"              
         if bmi1 >= 30: 
                      print "Your are obese"                    


if q=="lbs":
          w2 = input("Please Enter your weightin lbs:")
          bmi2 = w2/((h*h)*(39.37*39.37)*703) 
          print "Your BMI is:", bmi2

          if bmi2<= 18.5: 
                        print "Your are underweight."
          if bmi2>18.5 & bmi2<24.9: 
                                  print "Your weight is normal."
          if bmi2>25 & bmi2<29.9: 
                                print "Your are overweight"         
          if bmi2>=30: 
                     print "Your are obese" 

AUSGABE

Please Enter your height in meters:1.52
Do you want to enter your weight in kg or lbs?kg
Please Enter your weight in kgs:51
Your BMI is 22.074099723
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bmi.py", line 11, in <module>
    if bmi1 > 18.5 & bmi1 < 24.9: 
TypeError: unsupported operand type(s) for &: 'float' and 'float'

Wohin gehe ich falsch? Jemand lass es mich wissen..

Dank :).

InformationsquelleAutor user1345589 | 2012-04-20
Schreibe einen Kommentar