a weight calorie predictor
To upload files, please first save the app
import streamlit as st
import numpy as np
st.title("Weight & Calorie Calculator")
st.write("""
This app helps you calculate your daily caloric needs based on your weight, activity level, and goals.
""")
# User inputs
weight = st.number_input("Enter your weight (kg)", min_value=30.0, max_value=300.0, value=70.0)
activity_level = st.select_slider(
"Select your activity level",
options=["Sedentary", "Lightly Active", "Moderately Active", "Very Active", "Extra Active"],
value="Lightly Active"
)
goal = st.radio(
"What is your goal?",
["Maintain Weight", "Lose Weight", "Gain Weight"]
)
# Activity level multipliers
activity_multipliers = {
"Sedentary": 1.2,
"Lightly Active": 1.375,
"Moderately Active": 1.55,
"Very Active": 1.725,
"Extra Active": 1.9
}
# Calculate BMR using Mifflin-St Jeor Equation (simplified version)
bmr = (10 * weight) + 625 # Simplified formula
# Calculate TDEE (Total Daily Energy Expenditure)
tdee = bmr * activity_multipliers[activity_level]
# Adjust calories based on goal
if goal == "Lose Weight":
recommended_calories = tdee - 500
elif goal == "Gain Weight":
recommended_calories = tdee + 500
else:
recommended_calories = tdee
# Display results
st.header("Your Results")
col1, col2, col3 = st.columns(3)
with col1:
st.metric(
label="Base Metabolic Rate",
value=f"{bmr:.0f} cal"
)
with col2:
st.metric(
label="Daily Energy Expenditure",
value=f"{tdee:.0f} cal"
)
with col3:
st.metric(
label="Recommended Daily Calories",
value=f"{recommended_calories:.0f} cal",
delta=f"{recommended_calories - tdee:.0f} cal" if goal != "Maintain Weight" else None
)
# Additional information
st.subheader("What These Numbers Mean")
st.write("""
- **Base Metabolic Rate (BMR)**: The number of calories your body burns at rest
- **Daily Energy Expenditure (TDEE)**: Total calories burned including activity
- **Recommended Daily Calories**: Adjusted calories based on your goal
""")
st.info("""
Please note: This is a simplified calculation and should be used as a general guide only.
For more accurate recommendations, consult with a healthcare professional or registered dietitian.
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?