File size: 5,584 Bytes
11fa257 6f41800 3c1d725 11fa257 46b19ef 11fa257 d5769f9 11fa257 d5769f9 46b19ef 7b6e912 d5769f9 46b19ef d5769f9 6f41800 46b19ef 6f41800 7b6e912 46b19ef 7b6e912 d5769f9 46b19ef d5769f9 46b19ef d5769f9 46b19ef d5769f9 6f41800 46b19ef d5769f9 46b19ef d5769f9 46b19ef d5769f9 46b19ef 2db6d4a f8d8508 8d60103 f8d8508 2db6d4a 8d60103 f8d8508 8d60103 2db6d4a 8d60103 2db6d4a 8d60103 2db6d4a f8d8508 8d60103 2db6d4a f8d8508 8d60103 2db6d4a |
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
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]}")
# BMR Calculator
import streamlit as st
import pandas as pd
import os
from datetime import datetime
# Constants
GRAVITATIONAL_FORCE = 9.8 # Earth's gravitational force in m/s^2
POUND_TO_KG = 0.453592 # Conversion factor from pounds to kilograms
INCH_TO_METER = 0.0254 # Conversion factor from inches to meters
CALORIES_PER_KG_MUSCLE = 13 # Average additional calories burned per day per kg of muscle gained
# Convert pounds to kilograms
def pounds_to_kg(pounds):
return pounds * POUND_TO_KG
# Convert feet and inches to meters
def feet_inches_to_meters(feet, inches):
total_inches = feet * 12 + inches
return total_inches * INCH_TO_METER
# Calculate Calories Burned Lifting Weights
def calculate_calories_burned(mass_kg, height_diff, sets, reps, duration_hours):
total_mass_lifted = mass_kg * sets * reps
joules_per_rep = total_mass_lifted * GRAVITATIONAL_FORCE * height_diff
joules_total = joules_per_rep * duration_hours * 3600 / (sets * reps) # Assuming continuous lifting for the duration
return joules_total / 4184 # Convert joules to kilocalories
# Calculate Additional Daily Calorie Burn from Muscle Gain
def estimate_additional_calorie_burn(weight_kg, duration_months):
muscle_gain = weight_kg * duration_months * 0.025 # Estimate muscle gain: 2.5% of lifted weight per month
return muscle_gain * CALORIES_PER_KG_MUSCLE
# UI
st.title('ποΈ Advanced Calorie Counter for Weightlifting ποΈ')
with st.form('input_form'):
feet = st.number_input('Height (feet):', min_value=0, value=5)
inches = st.number_input('Height (inches):', min_value=0, value=11)
weight = st.number_input('Enter the weight lifted (lbs):', min_value=0.0, value=30.0)
sets = st.number_input('Number of sets:', min_value=1, value=10)
reps = st.number_input('Repetitions per set:', min_value=1, value=10)
duration_hours = st.number_input('Duration of session (hours):', min_value=0.1, value=1.0)
duration_months = st.number_input('Duration of regular training (months):', min_value=1, value=1)
submitted = st.form_submit_button('Calculate')
if submitted:
height_meters = feet_inches_to_meters(feet, inches)
weight_kg = pounds_to_kg(weight)
calories_burned = calculate_calories_burned(weight_kg, height_meters, sets, reps, duration_hours)
additional_calories = estimate_additional_calorie_burn(weight_kg, duration_months)
st.success(f'π₯ Calories Burned in Session: {calories_burned:.2f} kcal')
st.success(f'π Additional Daily Calorie Burn from Muscle Gain: {additional_calories:.2f} kcal/day')
# Display history
st.sidebar.header('π History')
for file in load_history():
if st.sidebar.button(f'π
{file}', key=file):
df = pd.read_csv(file)
st.sidebar.write(df)
|