awacke1's picture
Create backup.app.py
ea2481a
import streamlit as st
# Function to calculate calories burned during swimming based on swim style, now in pounds
def calories_swim(time_hr, weight_lb, style_mets):
return (time_hr * style_mets * 3.5 * weight_lb) / 10
# Function to calculate calories burned during pull-ups based on grip style
def calories_pullup(reps, weight, grip_style_factor):
return (reps * 5 * weight) / 150 * grip_style_factor
# Streamlit UI
st.title("Calories Burned Calculator πŸŠβ€β™‚οΈπŸ’ͺ")
st.sidebar.header("Input Parameters πŸ› οΈ")
# Swimming parameters
time_swim = st.sidebar.slider("Swimming Time (hours)", 0.0, 5.0, 2.0)
weight = st.sidebar.number_input("Your weight (lbs)", 100, 300, 175)
# Pull-Up parameters
reps = st.sidebar.slider("Number of Pull-Ups", 0, 500, 200)
# Choose Exercise Type
st.sidebar.subheader("Choose Exercise Type πŸ€Έβ€β™‚οΈ")
exercise_type = st.sidebar.selectbox(
"",
["Swim Jim πŸŠβ€β™‚οΈ", "Ring King πŸ‘‘", "Both Boost πŸš€"]
)
# Revised Swim Styles with METs to meet your requirement
swim_styles = {
"Treading Water 🌊": 6,
"Backstroke πŸŠβ€β™‚οΈ": 9,
"Breaststroke 🐸": 10,
"Freestyle Light πŸ¦‹": 11,
"Freestyle Vigorous πŸš€": 14.3,
"Butterfly πŸ¦‹": 14.3,
"Dog Paddle 🐢": 7
}
# Grip Styles with factors
grip_styles = {
"Standard 🌟": 1,
"Mixed Grip ✨": 1.1,
"Wide Grip 🌠": 1.2
}
st.sidebar.subheader("Choose Swim Style 🌊")
swim_style = st.sidebar.selectbox(
"",
list(swim_styles.keys())
)
st.sidebar.subheader("Choose Ring Style πŸͺ")
grip_style = st.sidebar.selectbox(
"",
list(grip_styles.keys())
)
# Calculation
calories_from_swimming = calories_swim(time_swim, weight, swim_styles[swim_style])
calories_from_pullups = calories_pullup(reps, weight, grip_styles[grip_style])
# Display Results
st.subheader(f"Calories Burned πŸ”₯")
if exercise_type == "Swim Jim πŸŠβ€β™‚οΈ":
st.write(f"Calories burned from swimming: {calories_from_swimming:.2f}")
elif exercise_type == "Ring King πŸ‘‘":
st.write(f"Calories burned from pull-ups: {calories_from_pullups:.2f}")
else:
total_calories = calories_from_swimming + calories_from_pullups
st.write(f"Total calories burned: {total_calories:.2f}")
st.subheader("Muscle Groups Worked 🦾")
if exercise_type == "Swim Jim πŸŠβ€β™‚οΈ":
st.write("Swimming works the back, shoulders, arms, and legs.")
elif exercise_type == "Ring King πŸ‘‘":
st.write("Pull-ups work the back, biceps, and forearms.")
else:
st.write("Doing both exercises works almost all major muscle groups!")
st.subheader(f"Swim Style: {swim_style} 🌊")
st.write(f"METS for chosen style: {swim_styles[swim_style]}")
st.subheader(f"Ring Style: {grip_style} πŸͺ")
st.write(f"Factor for chosen grip: {grip_styles[grip_style]}")