-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_project.py
More file actions
103 lines (94 loc) · 5.36 KB
/
final_project.py
File metadata and controls
103 lines (94 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
def main():
print("Welcome to your personal health and nutrition supporting tool!")
print()
personal_name = input("What is your name, babe? ")
print(f"Hello, {personal_name}! Let's get started with BMI and BMR calculations. I need your help with some personal information.")
calculating_scale = int(input("Which scale would you like to use for your calculations? (1 for Metric, 2 for Imperial): "))
metric_bmi = None
if calculating_scale == 1:
print("You have chosen the Metric scale. Please enter your height in meters, and your weight in kilograms.")
metric_height = float(input("Please enter your height in meters (e.g., 1.75): "))
metric_weight = float(input("Please enter your weight in kilograms (e.g., 70): "))
metric_bmi = metric_weight / (metric_height ** 2)
else:
print("You have chosen the Imperial scale. Please enter your height in feet, and your weight in pounds.")
imperial_height = float(input("Please enter your height in feet (e.g., 5.8): "))
imperial_weight = float(input("Please enter your weight in pounds (e.g., 150): "))
# Convert height from feet to meters and weight from pounds to kilograms
metric_height = imperial_height * 0.3048 # Convert feet to meters
metric_weight = imperial_weight * 0.453592 # Convert pounds to kilograms
metric_bmi = metric_weight / (metric_height ** 2)
# Calculate BMR
age = int(input("Please enter your age in years: "))
gender = input("Are you a male or female? (M/F): ").strip().upper()
activity_level = int(input("Please identify your activity level: 1. Sedentary (little or no exercise), 2. Lightly active (1-3 days/week), 3. Moderately active (3-5 days/week), 4. Very active (6-7 days a week), 5. Super active (twice a day): "))
if gender == 'M':
bmr = activity_level * (66.5 + (13.75 * metric_weight) + (5.003 * (metric_height * 100)) - (6.755 * age))
else:
bmr = activity_level * (655.1 + (9.563 * metric_weight) + (1.850 * (metric_height * 100)) - (4.676 * age))
personal_goal = int(input("What is your personal goal? (1 for weight loss, 2 for weight maintenance, 3 for weight gain): "))
if personal_goal == 1:
bmr -= 500 # Subtract 500 calories for weight loss
elif personal_goal == 2:
bmr = bmr # Maintain current BMR
else:
bmr += 300 # Add 300 calories for weight gain
# Break down BMR into macronutrients
if metric_bmi < 18.5:
protein_level = 1.2 # Higher protein for weight gain, unit: grams per kg
protein_weight = protein_level * metric_weight # Calculate protein intake in grams
protein_calories = protein_weight * 4 # Convert grams to calories
elif 18.5 <= metric_bmi < 24.9:
protein_level = 1.0 # Standard protein intake, unit: grams per kg
protein_weight = protein_level * metric_weight
protein_calories = protein_weight * 4
else:
protein_level = 0.8 # Lower protein intake for weight loss, unit: grams per kg
protein_weight = protein_level * metric_weight
protein_calories = protein_weight * 4
fat_calories = bmr * 0.25 # 25% of BMR from fat
fat_weight = fat_calories / 9 # Convert calories to grams of fat
carb_calories = bmr - (protein_calories + fat_calories) # Remaining calories from carbohydrates
carb_weight = carb_calories / 4 # Convert calories to grams of carbohydrates
print()
# Calculate fiber intake
if metric_bmi < 18.5:
fiber_intake = 25 # Recommended fiber intake for underweight individuals
elif 18.5 <= metric_bmi < 24.9:
fiber_intake = 30 # Recommended fiber intake for healthy individuals
else:
fiber_intake = 35 # Recommended fiber intake for overweight/obese individuals
# Final output
print("Here is your personalized health and nutrition breakdown:")
print(f"Name: {personal_name}")
print(f"Age: {age} years old")
print(f"Gender: {gender}")
if calculating_scale == 1:
print("Scale: Metric")
print(f"Height: {metric_height:.2f} meters")
print(f"Weight: {metric_weight:.1f} kg")
else:
print("Scale: Imperial")
print(f"Height: {imperial_height:.2f} feet")
print(f"Weight: {imperial_weight:.1f} lbs")
if metric_bmi < 18.5:
print(f"BMI: {metric_bmi:.1f}")
print("BMI Category: Underweight")
elif 18.5 <= metric_bmi < 24.9:
print(f"BMI: {metric_bmi:.1f}")
print("BMI Category: Healthy")
elif 25 <= metric_bmi < 29.9:
print(f"BMI: {metric_bmi:.1f}")
print("BMI Category: Overweight")
else:
print(f"BMI: {metric_bmi:.1f}")
print("BMI Category: Obese")
print(f"Your personal goal: {'Weight Loss' if personal_goal == 1 else 'Weight Maintenance' if personal_goal == 2 else 'Weight Gain'}")
print(f"BMR: {bmr:.0f} calories/day")
print(f"Recommended Daily Protein Intake: {protein_weight:.1f} grams ({protein_calories:.0f} calories)")
print(f"Recommended Daily Fat Intake: {fat_weight:.1f} grams ({fat_calories:.0f} calories)")
print(f"Recommended Daily Carbohydrate Intake: {carb_weight:.1f} grams ({carb_calories:.0f} calories)")
print(f"Recommended Daily Fiber Intake: {fiber_intake} grams")
print("Thank you for using the tool! Remember to consult with a healthcare professional for personalized advice.")
if __name__ == '__main__':
main()