2017-03-31 107 views
-10

它從昨天開始運行良好,但現在它給了我錯誤 - (初學者)這將最初確定你的身體質量指數,確定你是超重,肥胖還是體重不足。這樣既解決了熱量需求和蛋白質,脂肪和碳水化合物的需求擊穿爲什麼這個Python代碼給我錯誤,幫我

import time 
    print("Welcome to My cal calc") 
    print("Please sign up first.") 
    name=input("Name: ") 
    email=input("Email: ") 
    print("How old are you?") 
    age=input("Age: ") 
    if age<=18: 
      print("Sorry, this app is only for people aged 18 years old or older") 
      import sys 
      sys.exit() 
    else age >=18: 
      print("Thank you! Let's proceed!") 
    print("What is your weight in kilograms?") 
    kg=input(Weight: ") 
    print("What is your height?") 
    feet=input("Feet: ") 
    inches=input("Inches: ") 
    Total inches=(inches + (feet * 12)) 
    pounds=kg * 2.2 
    print("When converted to pounds, your weight is: ") pounds ("lbs") 
    meters=(((feet * 12) + inches) * 0.0254) 
    print("When converted to meters, your height is: " meters "(m") 
    print("Let's solve for your ideal body weight (IBW)") 
    print("Are you male or female?: " 
    sex=input("sex: ") 
    if sex=female: 
       Total inches-60=leftoverinches 
       leftoverinches + 5 + 100= IBW 
       print("Your ideal body weight (IBW) is: ") IBW ("in lbs") 
    else sex=male: 
       Total inches - 60 = leftoverinches 
       leftoverinches + 6 + 106 = IBW 
       print ("Your ideal body weight (IBW) is: " IBW (in lbs") 
    print("Let us now calculate your BMI (Body Mass Index) result: " 
    BMI=kg/(meters * meters) 
    print("Your BMI is: ") BMI 
    print(Here is my interpretation: " 
       if BMI <= 18.5 = underweight 
        BMI <= 18.5: 
        print ("You are undeweight") 
       elif BMI==18.6-24.9 = normal weight 
        BMI==18.6-24.9: 
        print("You have normal weight") 
       elif BMI==25-29.9= overweight 
         BMI==25-29.9: 
        print("You are overweight") 
       else BMI>=30=obese 
         BMI>=30: 
         print("You are obese") 
          if BMI=underweight: 
            print("Based on ideal body weight (IBW), your number of total calories per day should be: " 
            Total calories per day=((IBW/2.2) * 35) 
            print("Your total calories per day is:") Total calories per day ("cal/kg") 
            print("You should consume the following amounts of carbohydrates, proteins and fats per day") 
            carbohydrates=((Total calories per day * 0.5)/4) 
            proteins=((Total calories per day * 0.2)/4) 
            fats=((Total calories per day * 0.3)/4) 
            print(" Carbohydrates: ") carbohydrates ("grams") 
            print ("Proteins: ") proteins ("grams") 
            print ("Fats: ") fats ("grams") 
           elif BMI=normal weight: 
            print("Based on ideal body weight (IBW), your number of total calories per day should be: " 
            Total calories per day=((IBW/2.2) * 35) 
            print("Your total calories per day is:") Total calories per day ("cal/kg") 
            print("You should consume the following amounts of carbohydrates, proteins and fats per day") 
            carbohydrates=((Total calories per day * 0.5)/4) 
            proteins=((Total calories per day * 0.2)/4) 
            fats=((Total calories per day * 0.3)/4) 
            print(" Carbohydrates: ") carbohydrates ("grams") 
            print ("Proteins: ") proteins ("grams") 
            print ("Fats: ") fats ("grams") 
          elif BMI=overweight: 
             print("Based on ideal body weight (IBW), your number of total calories per day should be: " 
             Total calories per day = ((IBW/2.2) * 35) 
             TCPDFat=(Total calories per day - 1000) 
             print("Your total calories per day is: ") TCPDFat ("cal/kg") 
             print ("You should consume the following amounts of carbohydrates, proteins and fats per day") 
             carbohydrates=((Total calories per day * 0.5)/4) 
            proteins=((Total calories per day * 0.2)/4) 
            fats=((Total calories per day * 0.3)/4) 
            print(" Carbohydrates: ") carbohydrates ("grams") 
            print ("Proteins: ") proteins ("grams") 
            print ("Fats: ") fats ("grams") 
           else BMI= obese: 
             print("Based on ideal body weight (IBW), your number of total calories per day should be: " 
              Total calories per day = ((IBW/2.2) * 35) 
             TCPDFat=(Total calories per day - 1000) 
             print("Your total calories per day is: ") TCPDFat ("cal/kg") 
             print ("You should consume the following amounts of carbohydrates, proteins and fats per day") 
             carbohydrates=((Total calories per day * 0.5)/4) 
            proteins=((Total calories per day * 0.2)/4) 
            fats=((Total calories per day * 0.3)/4) 
            print(" Carbohydrates: ") carbohydrates ("grams") 
            print ("Proteins: ") proteins ("grams") 
            print ("Fats: ") fats ("grams") 
    import sys 
    sys.exit() 
+5

調試是一個重要的技能,最好通過實踐來學習。提示:調試技巧不包括Stack Overflow轉儲代碼​​。 –

+0

下一次,請包含完整的錯誤消息以及您已嘗試解決錯誤的內容。 – timgeb

+1

只看語法亮點 –

回答

1

你忘了引號在線路:

kg=input(Weight: ") 

它應該是:

kg=input("Weight: ") 
+2

這不是唯一的問題 –

相關問題