为什么这个python代码给了我错误,帮我

2024-06-03 14:48: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()

Tags: youyouristotalprintbmigramsweight