Protein Intake Calculator
Calculate your recommended daily protein intake based on weight, goal, and activity level.
Frequently Asked Questions
Code Implementation
def protein_needs(weight_kg, activity_level, goal):
"""
Calculate daily protein needs (g/day).
activity_level: "sedentary" | "light" | "moderate" | "heavy" | "athlete"
goal: "maintain" | "lose_fat" | "build_muscle"
"""
# Base multiplier per kg of body weight
base = {
"sedentary": 0.8,
"light": 1.2,
"moderate": 1.4,
"heavy": 1.6,
"athlete": 1.8,
}
multiplier = base.get(activity_level, 1.2)
# Adjust for goal
if goal == "build_muscle":
multiplier = max(multiplier, 1.6)
multiplier = min(multiplier + 0.4, 2.2)
elif goal == "lose_fat":
multiplier = max(multiplier + 0.4, 1.8) # preserve lean mass
return weight_kg * multiplier
def lean_body_mass_based(weight_kg, body_fat_pct, goal):
"""Calculate protein from lean body mass for high body-fat individuals."""
lbm = weight_kg * (1 - body_fat_pct / 100)
multiplier = 1.8 if goal == "build_muscle" else (2.0 if goal == "lose_fat" else 1.6)
return lbm * multiplier
# Example usage
print("=== Total body weight method ===")
for activity in ["sedentary", "light", "moderate", "heavy", "athlete"]:
g = protein_needs(75, activity, "build_muscle")
print(f" {activity:10}: {g:.0f} g/day")
print("\n=== LBM method (75 kg, 20% body fat) ===")
for goal in ["maintain", "build_muscle", "lose_fat"]:
g = lean_body_mass_based(75, 20, goal)
print(f" {goal:15}: {g:.0f} g/day")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.