while True:
gender = input("What is your gender? (M/male or F/female): ")
if gender.lower() in ["male", "m", "female", "f"]:
break
else:
print("Invalid input, please try again!")
while True:
try:
weight = float(input("What is your weight? (kg): "))
break
except ValueError:
print("Invalid input, please try again!")
while True:
try:
height = float(input("What is your height? (cm): "))
break
except ValueError:
print("Invalid input, please try again!")
while True:
try:
age = float(input("What is your age?: "))
break
except ValueError:
print("Invalid input, please try again!")
def health_plan(gender, age, weight, height):
bmi = weight/(height*height*0.0001)
if 18.5<=bmi<=24.9:
print("You are having a healthy lifestyle!")
else:
print("You are not having a healthy lifestyle!")
activity_index_table = [1.2, 1.375, 1.55, 1.725, 1.9]
print("Activity frequency: 1.low, 2.light 3.moderate 4.active, 5.very active")
while True:
try:
activity_choice = int(input("Choose your activity frequency! (1-5): "))
if 1 <= activity_choice <= 5:
activity_factor = activity_index_table[activity_choice - 1]
break
else:
print("Invalid input, please enter a number between 1 and 5!")
except ValueError:
print("Invalid input, please enter a number between 1 and 5!")
if gender.lower() == "m" or gender.lower() == "male":
bmr = 10 * weight + 6.25 * height - 5 * age + 5
else:
bmr = 10 * weight + 6.25 * height - 5 * age - 161
calories = int(bmr * activity_factor)
print("Fitness goal: 1. Lose weight, 2. Maintain weight 3. Gain muscle")
while True:
try:
goal = int(input("What is your fitness goal? (choose 1-3)? "))
if 1 <= goal <= 3:
break
else:
print("Invalid input, please choose between 1 and 3!")
except ValueError:
print("Invalid input, please enter a number between 1 and 3!")
workouts = {"Cardio: 3-5 days/week", "Strength: 2 days/week"}
if goal == 1: # Lose weight
calories_intake = calories - 500
workouts = ["Cardio: 3-5 days/week", "Strength: 2 days/week", "Stretching: 1 day/week"]
elif goal == 3: # Gain muscle
calories_intake = calories + 300
workouts = ["Strength: 4-5 days/week", "Cardio: 1-2 days/week", "Core: 2 days/week"]
else: # Maintain weight
calories_intake = calories
workouts = ["Strength: 2 days/week", "Cardio: 2 days/week", "Yoga: 1 day/week"]
return calories_intake, workouts
recommended_calories, workout_plan = health_plan(gender, age, weight, height)
print(f"Your recommended daily calories intake: {recommended_calories} kcal")
print("Your recommended workouts plan:")
for workout in workout_plan:
print(f"- {workout}")
#the process of making this program code has the assistance of chatgpt. It provides the
basic framework for my code and solve error as well as several adjustments