🛠️ToolsShed

カロリー計算ツール

年齢、体重、身長、活動量に基づいて1日のカロリー必要量を計算します。

Mifflin-St Jeor式に基づく推定値です。個別の栄養アドバイスは医療専門家または管理栄養士にご相談ください。

よくある質問

コード実装

def bmr_mifflin(weight_kg, height_cm, age, sex):
    """
    Mifflin-St Jeor BMR formula.

    Parameters:
        weight_kg - body weight in kilograms
        height_cm - height in centimetres
        age       - age in years
        sex       - 'male' or 'female'

    Returns Basal Metabolic Rate in kcal/day.
    """
    bmr = 10 * weight_kg + 6.25 * height_cm - 5 * age
    return bmr + 5 if sex == "male" else bmr - 161


ACTIVITY_MULTIPLIERS = {
    "sedentary":    1.2,   # little or no exercise
    "light":        1.375, # 1-3 days/week
    "moderate":     1.55,  # 3-5 days/week
    "active":       1.725, # 6-7 days/week
    "very_active":  1.9,   # twice/day or physical job
}


def tdee(weight_kg, height_cm, age, sex, activity_level="moderate"):
    """Total Daily Energy Expenditure = BMR × activity multiplier."""
    b = bmr_mifflin(weight_kg, height_cm, age, sex)
    return b * ACTIVITY_MULTIPLIERS[activity_level]


def macros(calories, protein_pct=0.30, carb_pct=0.40, fat_pct=0.30):
    """
    Split calories into macronutrient grams.
    Default split: 30% protein / 40% carbs / 30% fat.
    protein & carbs = 4 kcal/g; fat = 9 kcal/g.
    """
    return {
        "protein_g": calories * protein_pct / 4,
        "carbs_g":   calories * carb_pct   / 4,
        "fat_g":     calories * fat_pct    / 9,
    }


# Example: 30-year-old male, 80 kg, 175 cm, moderately active
b = bmr_mifflin(80, 175, 30, "male")
t = tdee(80, 175, 30, "male", "moderate")
m = macros(t)

print(f"BMR:            {b:.0f} kcal/day")
print(f"TDEE (moderate): {t:.0f} kcal/day")
print(f"Protein:        {m['protein_g']:.0f} g")
print(f"Carbs:          {m['carbs_g']:.0f} g")
print(f"Fat:            {m['fat_g']:.0f} g")

# Weight-loss / gain targets
print(f"\nWeight loss (-500 kcal): {t - 500:.0f} kcal/day")
print(f"Weight gain (+500 kcal): {t + 500:.0f} kcal/day")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.