print('HEGO FITNESS APP')
print('hello! Welcome to HEGO fitness program')
import mysql.connector
from datetime import datetime
# Function to connect to the MySQL database
def connect_to_db():
return mysql.connector.connect(
host="localhost",
user="root", # Replace with your MySQL username
password="12345", # Replace with your MySQL password
database="health" # Replace with your MySQL database name
# Function to add a user to the database
def add_user(user_id, name, age, blood_group, gender, height,
weight,bmi, fitness_plan, target_weight, level, routine, time_spent,
workout_days, fitness_goal, dietary_preference, activity_level, nationality):
db = connect_to_db()
cursor = db.cursor()
cursor.execute("""
INSERT INTO client (user_id, name, age, blood_group, gender, height,
weight,bmi, fitness_plan, target_weight, level, routine, time_spent,
workout_days, fitness_goal, dietary_preference, activity_level,
nationality,date)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s,%s,%s)
""", (user_id, name, age, blood_group, gender, height, weight,bmi,
fitness_plan, target_weight, level, routine, time_spent, workout_days,
fitness_goal, dietary_preference, activity_level,
nationality,datetime.now().date()))
db.commit()
cursor.close()
db.close()
# Function to record progress
def record_progress(user_id, weight_progress,bmi,height):
db = connect_to_db()
cursor = db.cursor()
cursor.execute("INSERT INTO
PROGRESS(user_id,weight,bmi,date)VALUES(%s,%s,%s,%s)",
(user_id,weight,bmi,datetime.now().date()))
db.commit()
cursor.close()
db.close()
# Function to get workout plans based on fitness plan and level
def get_workout_plans(fitness_plan, level, workout_days_count):
all_workouts = {
'Basic fitness plan': {
'Beginner': {
1: ['Bodyweight Exercises'],
2: ['Walking', 'Bodyweight Exercises'],
3: ['Yoga', 'Bodyweight Exercises', 'Walking'],
4: ['Light Stretching', 'Bodyweight Exercises', 'Walking', 'Yoga'],
5: ['Light Cardio', 'Bodyweight Exercises', 'Walking', 'Yoga', 'Core
Workouts'],
6: ['Walking', 'Yoga', 'Core Workouts', 'Bodyweight Exercises',
'Light Cardio', 'Full Body Workout'],
7: ['Walking', 'Yoga', 'Core Workouts', 'Bodyweight Exercises',
'Light Cardio', 'Full Body Workout', 'Active Recovery']
},
'Intermediate': {
1: ['Circuit Training'],
2: ['Running', 'Circuit Training'],
3: ['Swimming', 'Running', 'Circuit Training'],
4: ['HIIT', 'Circuit Training', 'Running', 'Swimming'],
5: ['Resistance Training', 'Running', 'Swimming', 'Circuit
Training', 'HIIT'],
6: ['Active Recovery', 'Resistance Training', 'Running',
'Swimming', 'HIIT', 'Circuit Training'],
7: ['Flexibility Training', 'Active Recovery', 'Resistance Training',
'Running', 'Swimming', 'HIIT', 'Circuit Training']
},
'Advanced': {
1: ['HIIT'],
2: ['CrossFit', 'HIIT'],
3: ['Advanced Weightlifting', 'CrossFit', 'HIIT'],
4: ['Plyometrics', 'CrossFit', 'Advanced Weightlifting', 'HIIT'],
5: ['Endurance Training', 'CrossFit', 'Plyometrics', 'Advanced
Weightlifting', 'HIIT'],
6: ['Sports-Specific Drills', 'Endurance Training', 'CrossFit',
'Plyometrics', 'Advanced Weightlifting', 'HIIT'],
7: ['Recovery Techniques', 'Sports-Specific Drills', 'Endurance
Training', 'CrossFit', 'Plyometrics', 'Advanced Weightlifting', 'HIIT']
},
'Weight loss plan': {
'Beginner': {
1: ['Walking', 'Bodyweight Exercises'],
2: ['Jogging', 'Bodyweight Exercises'],
3: ['Circuit Training', 'Yoga'],
4: ['HIIT', 'Walking'],
5: ['Swimming', 'Bodyweight Exercises'],
6: ['Cycling', 'Light Cardio', 'Yoga'],
7: ['Active Recovery', 'Bodyweight Exercises', 'Yoga']
},
'Intermediate': {
1: ['Running', 'Circuit Training'],
2: ['HIIT', 'Swimming'],
3: ['Cycling', 'Resistance Training'],
4: ['Endurance Running', 'HIIT'],
5: ['Resistance Training', 'Cardio'],
6: ['Flexibility Training', 'Active Recovery'],
7: ['Sports-Specific Drills', 'Resistance Training']
},
'Advanced': {
1: ['Plyometrics', 'HIIT'],
2: ['CrossFit', 'Advanced Weightlifting'],
3: ['Endurance Training', 'HIIT'],
4: ['Strength Training', 'Plyometrics'],
5: ['Advanced Cardio', 'Resistance Training'],
6: ['Recovery Techniques', 'Flexibility Training'],
7: ['Sports-Specific Drills', 'Endurance Training']
},
# Return the specified workout plan or a default if not available
default_workout = ['30 minutes of brisk walking', '15 minutes of
stretching', '10 minutes of core exercises']
return all_workouts.get(fitness_plan, {}).get(level,
{}).get(workout_days_count, default_workout)
# Function to get diet recipes based on fitness plan and nationality
def get_diet_recipes(fitness_plan, nationality):
diet_recipes = {
'Basic fitness plan': {
'Indian': {
'Breakfast': ['Oatmeal', 'Fruit Smoothie', 'Vegetable Poha'],
'Lunch': ['Quinoa Salad', 'Dal and Rice', 'Vegetable Curry'],
'Dinner': ['Grilled Chicken', 'Vegetable Stir Fry', 'Roti and Sabzi']
},
'Non-Indian': {
'Breakfast': ['Greek Yogurt', 'Fruit Salad', 'Scrambled Eggs'],
'Lunch': ['Caesar Salad', 'Grilled Chicken Sandwich', 'Quinoa
Bowl'],
'Dinner': ['Steak with Vegetables', 'Pasta Primavera', 'Fish Tacos']
},
'Weight loss plan': {
'Indian': {
'Breakfast': ['Vegetable Upma', 'Fruit Chaat', 'Moong Dal Chilla'],
'Lunch': ['Brown Rice and Vegetables', 'Vegetable Daal', 'Mixed
Salad'],
'Dinner': ['Grilled Fish', 'Mixed Vegetable Curry', 'Quinoa Salad']
},
'Non-Indian': {
'Breakfast': ['Avocado Toast', 'Protein Shake', 'Fruit Bowl'],
'Lunch': ['Chicken Salad', 'Vegetable Stir Fry', 'Tuna Salad'],
'Dinner': ['Stir-Fried Tofu', 'Chicken with Broccoli', 'Grilled
Shrimp']
},
return diet_recipes.get(fitness_plan, {}).get(nationality, {})
# Function to display workout and diet plans
def display_plans(user_id):
db = connect_to_db()
cursor = db.cursor()
cursor.execute("SELECT fitness_plan, level, workout_days, nationality
FROM client WHERE user_id = %s", (user_id,))
user_data = cursor.fetchone()
cursor.close()
db.close()
if user_data:
fitness_plan = user_data[0]
level = user_data[1]
workout_days_count = int(user_data[2])
nationality = user_data[3]
workouts = get_workout_plans(fitness_plan, level,
workout_days_count)
print("Workout Plans:")
for workout in workouts:
print(f"- {workout}")
recipes = get_diet_recipes(fitness_plan, nationality)
print("\nDiet Recipes:")
for meal_type, meal_options in recipes.items():
print(f"{meal_type}: {', '.join(meal_options)}")
else:
print("User ID not found.")
# Main program loop
while True:
print("\nSelect an option:")
print("1. Add user")
print("2. Record progress")
print("3. View diet plans")
print("4. View workout plans")
print("5. BMI calculator")
print("6. ask HEGOBOT for workout and diet recipies ")
print("7.Food composition and Calories")
print("8.Exit")
action = input("Select an option (1-8): ")
if action == '1':# Adding a new user
user_id = input("Enter user ID: ")
name = input("Enter name: ")
age = input("Enter age: ")
blood_group = input("Enter blood group: ")
print("Select gender:")
print("1. Male")
print("2. Female")
print("3. Other")
gender_choice = input("Enter choice (1-3): ")
gender = "Male" if gender_choice == '1' else "Female" if
gender_choice == '2' else "Other"
height = int(input("Enter height in cm: "))
weight = int(input("Enter weight in kg: "))
# Calculate BMI here
bmi = round(weight / ((height / 100) ** 2), 2)
print("YOUR BMI IS:", bmi)
if bmi < 18.5:
print('Yours is underweight')
elif 18.5 <= bmi < 25:
print('Yours is normal')
elif 25 <= bmi < 30:
print('Yours is overweight')
elif bmi >= 30:
print('Yours is obesity')
else:
print('Invalid')
print("Select fitness plan:")
print("1. Basic fitness plan")
print("2. Weight loss plan")
fitness_plan_choice = input("Enter choice (1-2): ")
fitness_plan = "Basic fitness plan" if fitness_plan_choice == '1'
else "Weight loss plan"
target_weight = input("Enter target weight in kg: ")
print("Select level:")
print("1. Beginner")
print("2. Intermediate")
print("3. Advanced")
level_choice = input("Enter choice (1-3): ")
level = "Beginner" if level_choice == '1' else "Intermediate" if
level_choice == '2' else "Advanced"
print("Select routine:")
print("1. Cardio")
print("2. Strength Training")
print("3. Flexibility")
routine_choice = input("Enter choice (1-3): ")
routine = "Cardio" if routine_choice == '1' else "Strength Training"
if routine_choice == '2' else "Flexibility"
time_spent = input("Time spent in minutes: ")
workout_days = input("How many workout days per week? Enter
number of days (1-7): ")
print("Select fitness goal:")
print("1. Fat Loss")
print("2. Muscle Gain")
print("3. Body Recomposition")
goal_choice = input("Enter choice (1-3): ")
fitness_goal = "Fat Loss" if goal_choice == '1' else "Muscle Gain" if
goal_choice == '2' else "Body Recomposition"
print("Select dietary preference:")
print("1. Vegetarian")
print("2. Non-Vegetarian")
dietary_preference_choice = input("Enter choice (1-2): ")
dietary_preference = "Vegetarian" if dietary_preference_choice ==
'1' else "Non-Vegetarian"
print("Select nationality:")
print("1. Indian")
print("2. Non-Indian")
nationality_choice = input("Enter choice (1-2): ")
nationality = "Indian" if nationality_choice == '1' else "Non-Indian"
# Pass bmi as a parameter to add_user
add_user(user_id, name, age, blood_group, gender, height, weight,
bmi, fitness_plan, target_weight, level, routine, time_spent, workout_days,
fitness_goal, dietary_preference, "Active", nationality)
print("User added successfully!")
elif action == '2':
# Recording progress
user_id = input("Enter user ID to record progress: ")
weight= int(input("Enter new weight in kg: "))
height=int(input("Enter current height:"))
bmi = round(weight/ ((height / 100) ** 2), 2)
record_progress(user_id, weight,bmi,height)
print("Progress recorded successfully!")
elif action == '3':
# View diet plans
user_id = input("Enter user ID to view diet plans: ")
# Fetch user data to get fitness plan and nationality
db = connect_to_db()
cursor = db.cursor()
cursor.execute("SELECT fitness_plan, nationality FROM client WHERE
user_id = %s", (user_id,))
user_data = cursor.fetchone()
cursor.close()
db.close()
if user_data:
fitness_plan = user_data[0]
nationality = user_data[1]
# Get and display diet recipes
recipes = get_diet_recipes(fitness_plan, nationality)
if recipes:
print("\nDiet Recipes:")
for meal_type, meal_options in recipes.items():
print(f"{meal_type}: {', '.join(meal_options)}")
else:
print("No diet recipes found.")
else:
print("User ID not found.")
elif action == '4':
# View workout plans
user_id = input("Enter user ID to view workout plans: ")
display_plans(user_id)
elif action == '5':
# BMI Calculator
print("Calculate your BMI")
height = float(input("Enter your height in cm: ")) / 100 # Convert to
meters
weight = float(input("Enter your weight in kg: "))
bmi = round(weight / (height ** 2), 2)
print("Your BMI is:", bmi)
if bmi < 18.5:
print("Yours is underweight")
elif 18.5 <= bmi < 25:
print("Yours is normal")
elif 25 <= bmi < 30:
print("Yours is overweight")
else:
print("Yours is obesity")
elif action == '6':
import random
class ChatBot:
def __init__(self):
self.responses = {
'greetings': ["Hello!", "Hi there!", "Hey, how can I help you?"],
'farewells': ["Goodbye!", "See you later!", "Bye, take care!"],
'thanks': ["You're welcome!", "No problem!", "Glad I could
help!"],
'congrats': ["Congrats!", "Well done!", "Awesome job!"],
'responses': {
'hi': "Hello! How can I assist you today?",
'hello': "Hi there! What can I do for you?",
'ok': "Okay! Let me know what you need.",
'welcome': "Welcome! I'm here to help you with your
fitness journey."
},
'recipes': {
'tamil_nadu': {
'Veg': "Vegetable Sambar: Lentil-based vegetable stew
served with brown rice.",
'Non-Veg': "Chettinad Chicken: Spicy chicken curry from
Chettinad."
},
'gujarat': {
'Veg': "Dhokla: Steamed fermented chickpea flour
cake.",
'Non-Veg': "Fish Curry: Spicy fish curry popular in coastal
regions."
},
'punjab': {
'Veg': "Palak Paneer: Spinach with cottage cheese.",
'Non-Veg': "Butter Chicken: Creamy chicken curry."
},
'maharashtra': {
'Veg': "Puran Poli: Sweet flatbread stuffed with lentil and
jaggery.",
'Non-Veg': "Bombay Duck Fry: Fried Bombay duck fish."
},
'delhi': {
'Veg': "Chole Bhature: Spiced chickpeas with fried
bread.",
'Non-Veg': "Mutton Korma: Spicy and rich mutton curry."
},
'jammu_and_kashmir': {
'Veg': "Nadru Yakhni: Lotus stem curry with yogurt
sauce.",
'Non-Veg': "Rogan Josh: Tender lamb cooked with
spices."
},
'kerala': {
'Veg': "Avial: Mixed vegetables in coconut and yogurt
sauce.",
'Non-Veg': "Meen Moilee: Fish cooked in coconut milk."
},
'karnataka': {
'Veg': "Bisi Bele Bath: Spiced rice with lentils and
vegetables.",
'Non-Veg': "Mangalorean Fish Curry: Spicy fish curry with
coconut."
},
'general': {
'Veg': "Quinoa Salad: Quinoa with chopped vegetables
and lemon dressing.",
'Non-Veg': "Grilled Chicken Salad: Chicken breast served
with mixed greens."
},
'meal_plans': {
'cutting': {
'Veg': "Vegetable Stir-fry: Mixed vegetables with tofu and
brown rice.",
'Non-Veg': "Grilled Chicken with Asparagus: Lean protein
with veggies."
},
'bulking': {
'Veg': "Paneer Tikka with Quinoa: Protein-rich meal with
carbs.",
'Non-Veg': "Chicken Biryani: Rice with spiced chicken for
energy."
},
'fat_loss': {
'Veg': "Lentil Soup: High-protein soup with veggies.",
'Non-Veg': "Fish Tacos: Light fish served in corn tortillas."
},
'muscle_gain': {
'Veg': "Chickpea Salad with Avocado: High-protein and
healthy fats.",
'Non-Veg': "Turkey Wrap: Lean turkey with whole grain
wrap."
},
},
'workout_plans': {
'cardio': "Cardio Plan: 30 minutes of running or cycling, 5
days a week.",
'fat_loss': "Fat Loss Plan: 4 days of strength training + 3
days of HIIT cardio.",
'weight_loss': "Weight Loss Plan: 5 days of mixed cardio
and strength workouts.",
'muscle_gain': "Muscle Gain Plan: 6-day split focusing on
heavy lifting.",
'body_recomposition': "Body Recomposition Plan: Mix of
strength training and cardio, 5 days a week.",
'yoga': "Yoga Plan: 3 days a week, focusing on flexibility
and core strength.",
'weight_training': "Weight Training Plan: 4-5 days a week
focusing on compound movements.",
'strength_training': "Strength Training Plan: 4 days focusing
on major muscle groups.",
'general': "A balanced mix of cardio and strength training:
30 minutes each."
},
'workout_splits': {
'muscle_gain': {
'split': "6-Day Workout Split: \nDay 1: Chest & Triceps \
nDay 2: Back & Biceps \nDay 3: Legs \nDay 4: Shoulders \nDay 5: Cardio &
Abs \nDay 6: Full Body \nDay 7: Rest",
'description': "Focus on heavy lifting with compound
movements and progressive overload."
},
'fat_loss': {
'split': "4-Day Workout Split: \nDay 1: Upper Body
(Push) \nDay 2: Lower Body \nDay 3: Upper Body (Pull) \nDay 4: Full Body
HIIT \nDay 5: Rest \nDay 6: Active Recovery \nDay 7: Rest",
'description': "Incorporate cardio and resistance training
to maximize calorie burn."
},
'weight_loss': {
'split': "5-Day Workout Split: \nDay 1: Cardio (30 mins) +
Strength Training \nDay 2: HIIT Workout \nDay 3: Active Recovery \nDay 4:
Strength Training (Full Body) \nDay 5: Cardio (45 mins) \nDay 6: Flexibility
Training (Yoga) \nDay 7: Rest",
'description': "Focus on both cardio and strength to
create a calorie deficit."
},
'yoga': {
'split': "Yoga Workout Split: \nDay 1: Hatha Yoga \nDay 2:
Vinyasa Flow \nDay 3: Rest or Gentle Stretching \nDay 4: Ashtanga Yoga \
nDay 5: Rest \nDay 6: Yin Yoga \nDay 7: Meditation",
'description': "Focus on mindfulness and flexibility with
various yoga styles."
},
'strength_training': {
'split': "Strength Training Split: \nDay 1: Upper Body \
nDay 2: Lower Body \nDay 3: Core \nDay 4: Full Body \nDay 5: Active
Recovery \nDay 6: Flexibility Training \nDay 7: Rest",
'description': "Target all major muscle groups for
balanced strength development."
},
'general': "A balanced mix of cardio and strength training:
30 minutes each."
def greet(self):
return random.choice(self.responses['greetings'])
def farewell(self):
return random.choice(self.responses['farewells'])
def thanks(self):
return random.choice(self.responses['thanks'])
def congrats(self):
return random.choice(self.responses['congrats'])
def respond_to_common_phrases(self, user_input):
responses = self.responses['responses']
for phrase, response in responses.items():
if phrase in user_input:
return response
return None
def get_recipes(self, state, diet_type=None):
recipes = self.responses['recipes'].get(state, {})
if diet_type:
# Convert diet_type to match the keys in the recipes
dictionary
diet_type = diet_type.capitalize() # Ensure it's capitalized
return recipes.get(diet_type, "Sorry, I don't have recipes for
that.")
else:
veg_recipe = recipes.get('Veg', "Sorry, I don't have Veg
recipes for that state.")
non_veg_recipe = recipes.get('Non-Veg', "Sorry, I don't have
Non-Veg recipes for that state.")
return f"Veg: {veg_recipe}\nNon-Veg: {non_veg_recipe}"
def get_meal_plans(self, meal_type, diet_type=None):
meal_plans=self.responses['meal_plans'].get(meal_type, {})
if diet_type:
# Convert diet_type to match the keys in the recipes
dictionary
diet_type = diet_type.capitalize() # Ensure it's capitalized
return meal_plans.get(diet_type, "Sorry, I don't have recipes
for that.")
else:
veg = meal_plans.get('Veg', "Sorry, I don't have Veg recipes
for that state.")
non_veg = meal_plans.get('Non-Veg', "Sorry, I don't have
Non-Veg recipes for that state.")
return f"Veg: {veg}\nNon-Veg: {non_veg}"
def get_workout_plans(self, workout_type):
return self.responses['workout_plans'].get(workout_type, "Sorry,
I don't have workout plans for that.")
def get_workout_split(self, plan_type):
split_info = self.responses['workout_splits'].get(plan_type, {})
if split_info:
return f"Workout Split:\n{split_info['split']}\nDescription:
{split_info.get('description', 'No description available.')}"
return "Sorry, I don't have information on that workout split."
def start_conversation(self):
print("ChatBot: Hey, how can I help you?")
while True:
user_input = input("You: ").lower()
if user_input == 'exit':
print(self.farewell())
break
common_response =
self.respond_to_common_phrases(user_input)
if common_response:
print(f"ChatBot: {common_response}")
elif "recipe" in user_input:
state = input("Please specify the state (e.g., tamil_nadu,
gujarat, etc.): ").lower()
diet_type = input("Please specify the diet type (Veg/Non-
Veg). Leave blank for both: ").capitalize()
if diet_type:
print(f"ChatBot: {self.get_recipes(state, diet_type)}")
else:
print(f"ChatBot: {self.get_recipes(state)}")
elif 'meal plan' in user_input:
meal_type = input("What type of meal plan do you want?
(cutting/bulking/fat_loss/muscle_gain) :").lower()
diet_type = input("Please specify the diet type (Veg/Non-
Veg). Leave blank for both: ").capitalize().strip() # Added strip() to
remove leading/trailing whitespace
if diet_type: # Check if diet_type is not empty
print(f"ChatBot: {self.get_meal_plans(meal_type,
diet_type)}")
else:
print(f"ChatBot: {self.get_meal_plans(meal_type)}")
elif "workout plan" in user_input:
plan_type = input("Please specify the plan type
(muscle_gain, fat_loss, etc.): ").lower()
print(f"ChatBot: {self.get_workout_split(plan_type)}")
else:
print("ChatBot: I'm not sure how to respond to that. Please
ask me something else.")
# Create an instance of the ChatBot
if __name__ == "__main__":
chatbot = ChatBot()
chatbot.start_conversation()
elif action == '7':
class FoodComposition:
def __init__(self):
self.macronutrients = {
'cutting': {
'0-18': {'Protein': '120g', 'Carbs': '150g', 'Fats': '50g',
'Fiber': '30g'},
'19-30': {'Protein': '150g', 'Carbs': '130g', 'Fats': '50g',
'Fiber': '30g'},
'31-50': {'Protein': '140g', 'Carbs': '120g', 'Fats': '60g',
'Fiber': '30g'},
'51+': {'Protein': '130g', 'Carbs': '100g', 'Fats': '60g', 'Fiber':
'25g'},
},
'bulking': {
'0-18': {'Protein': '130g', 'Carbs': '250g', 'Fats': '70g',
'Fiber': '35g'},
'19-30': {'Protein': '180g', 'Carbs': '300g', 'Fats': '80g',
'Fiber': '30g'},
'31-50': {'Protein': '160g', 'Carbs': '250g', 'Fats': '75g',
'Fiber': '30g'},
'51+': {'Protein': '150g', 'Carbs': '220g', 'Fats': '70g', 'Fiber':
'30g'},
},
'fat_loss': {
'0-18': {'Protein': '100g', 'Carbs': '120g', 'Fats': '40g',
'Fiber': '30g'},
'19-30': {'Protein': '120g', 'Carbs': '100g', 'Fats': '40g',
'Fiber': '30g'},
'31-50': {'Protein': '110g', 'Carbs': '90g', 'Fats': '50g',
'Fiber': '25g'},
'51+': {'Protein': '100g', 'Carbs': '80g', 'Fats': '50g', 'Fiber':
'25g'},
},
'muscle_gain': {
'0-18': {'Protein': '130g', 'Carbs': '250g', 'Fats': '70g',
'Fiber': '35g'},
'19-30': {'Protein': '180g', 'Carbs': '300g', 'Fats': '80g',
'Fiber': '30g'},
'31-50': {'Protein': '160g', 'Carbs': '250g', 'Fats': '75g',
'Fiber': '30g'},
'51+': {'Protein': '150g', 'Carbs': '220g', 'Fats': '70g', 'Fiber':
'30g'},
},
def calculate_bmr(self, weight, height, age, gender='male'):
"""Calculate Basal Metabolic Rate (BMR) using Mifflin-St Jeor
Equation."""
if gender == 'male':
return 10 * weight + 6.25 * height - 5 * age + 5
else:
return 10 * weight + 6.25 * height - 5 * age - 161
def calculate_caloric_needs(self, bmr, activity_level):
"""Estimate daily caloric needs based on activity level."""
if activity_level == 'sedentary':
return bmr * 1.2
elif activity_level == 'light':
return bmr * 1.375
elif activity_level == 'moderate':
return bmr * 1.55
elif activity_level == 'active':
return bmr * 1.725
elif activity_level == 'very active':
return bmr * 1.9
else:
return bmr # Default to BMR if activity level is unknown
def get_macronutrient_composition(self, goal, age):
for age_range in self.macronutrients[goal]:
min_age, max_age = map(int, age_range.split('-'))
if min_age <= age <= max_age:
return self.macronutrients[goal][age_range]
return "Sorry, I don't have macronutrient information for that
age range."
def start(self):
print("Welcome to the Food Composition Guide!")
while True:
goal = input("Please specify your goal (cutting, bulking,
fat_loss, muscle_gain) or type 'exit' to quit: ").lower()
if goal == 'exit':
print("Thank you for using the Food Composition Guide!")
break
if goal not in self.macronutrients:
print("Invalid goal. Please choose from cutting, bulking,
fat_loss, muscle_gain.")
continue
try:
age = int(input("Please specify your age: "))
weight = float(input("Please specify your weight in kg: "))
height = float(input("Please specify your height in cm: "))
# Provide options for gender
print("Please choose your gender:")
print("1. Male")
print("2. Female")
gender_choice = input("Enter 1 for Male or 2 for Female: ")
gender = 'male' if gender_choice == '1' else 'female' if
gender_choice == '2' else 'male'
# Provide options for activity level
print("Please choose your activity level:")
print("1. Sedentary (little or no exercise)")
print("2. Lightly active (light exercise/sports 1-3
days/week)")
print("3. Moderately active (moderate exercise/sports 3-5
days/week)")
print("4. Very active (hard exercise/sports 6-7 days a
week)")
print("5. Extra active (very hard exercise/physical job &
exercise 2x/day)")
activity_choice = input("Enter the number corresponding to
your activity level (1-5): ")
activity_levels = {
'1': 'sedentary',
'2': 'light',
'3': 'moderate',
'4': 'active',
'5': 'very active'
activity_level = activity_levels.get(activity_choice,
'sedentary')
# Calculate BMR and caloric needs
bmr = self.calculate_bmr(weight, height, age, gender)
caloric_needs = self.calculate_caloric_needs(bmr,
activity_level)
# Get macronutrient composition
composition = self.get_macronutrient_composition(goal,
age)
if isinstance(composition, dict):
print(f"\nFor your goal of {goal} at age {age}, the
recommended composition is:")
for nutrient, amount in composition.items():
print(f"{nutrient}: {amount}")
print(f"Your estimated daily caloric needs:
{caloric_needs:.2f} calories.")
else:
print(composition)
except ValueError:
print("Please enter valid values.")
# Create an instance of FoodComposition
if __name__ == "__main__":
food_composition = FoodComposition()
food_composition.start()
elif action == '8':
# Exiting the app
print('''Rate our app
1.5star(*****)
2.4star(****)
3.3star(***)
4.2star(**)
5.1star(*)
6.no stars''')
f=int(input('Rate our app:'))
e=input('comment your experience and thank you for using our
app:')
print(" Done by GANGA PRASATH and AJAYLIN")
break
else:
print("Invalid choice. Please select a valid option.")