Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Function to calculate calories burned during swimming
|
4 |
-
def calories_swim(time_hr, weight_kg):
|
5 |
-
METS = 10 # Metabolic Equivalent for swimming
|
6 |
-
return (time_hr * METS * 3.5 * weight_kg) / 200
|
7 |
|
8 |
# Function to calculate calories burned during pull-ups
|
9 |
-
def calories_pullup(weight, reps):
|
10 |
-
#
|
11 |
-
calories_per_pullup =
|
12 |
return calories_per_pullup * reps
|
13 |
|
14 |
# Streamlit UI
|
@@ -20,7 +20,7 @@ time_swim = st.sidebar.slider("Swimming Time (hours)", 0.0, 5.0, 2.0)
|
|
20 |
weight = st.sidebar.number_input("Your weight (lbs)", 100, 300, 175)
|
21 |
|
22 |
# Ring Exercise parameters
|
23 |
-
reps = st.sidebar.slider("Number of Pull-Ups", 0, 500,
|
24 |
|
25 |
st.sidebar.subheader("Choose Exercise Type π€ΈββοΈ")
|
26 |
exercise_type = st.sidebar.selectbox(
|
@@ -28,22 +28,35 @@ exercise_type = st.sidebar.selectbox(
|
|
28 |
["Swim Jim πββοΈ", "Ring King π", "Both Boost π"]
|
29 |
)
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
st.sidebar.subheader("Choose Swim Style π")
|
32 |
swim_style = st.sidebar.selectbox(
|
33 |
"",
|
34 |
-
|
35 |
)
|
36 |
|
37 |
st.sidebar.subheader("Choose Ring Style πͺ")
|
38 |
ring_style = st.sidebar.selectbox(
|
39 |
"",
|
40 |
-
|
41 |
)
|
42 |
|
43 |
# Calculation
|
44 |
weight_kg = weight * 0.453592
|
45 |
-
calories_from_swimming = calories_swim(time_swim, weight_kg)
|
46 |
-
calories_from_pullups = calories_pullup(weight, reps)
|
47 |
|
48 |
# Display
|
49 |
st.subheader(f"Calories Burned π₯")
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Function to calculate calories burned during swimming
|
4 |
+
def calories_swim(time_hr, weight_kg, style_factor):
|
5 |
+
METS = 10 # Base Metabolic Equivalent for swimming
|
6 |
+
return (time_hr * (METS * style_factor) * 3.5 * weight_kg) / 200
|
7 |
|
8 |
# Function to calculate calories burned during pull-ups
|
9 |
+
def calories_pullup(weight, reps, style_factor):
|
10 |
+
# Lifting full body weight per pull-up, adjusted by style
|
11 |
+
calories_per_pullup = weight * style_factor / 350
|
12 |
return calories_per_pullup * reps
|
13 |
|
14 |
# Streamlit UI
|
|
|
20 |
weight = st.sidebar.number_input("Your weight (lbs)", 100, 300, 175)
|
21 |
|
22 |
# Ring Exercise parameters
|
23 |
+
reps = st.sidebar.slider("Number of Pull-Ups", 0, 500, 200)
|
24 |
|
25 |
st.sidebar.subheader("Choose Exercise Type π€ΈββοΈ")
|
26 |
exercise_type = st.sidebar.selectbox(
|
|
|
28 |
["Swim Jim πββοΈ", "Ring King π", "Both Boost π"]
|
29 |
)
|
30 |
|
31 |
+
# Style factor adjustments
|
32 |
+
swim_style_factors = {
|
33 |
+
"Frog Kick πΈ": 1.0,
|
34 |
+
"Dolphin Kick π¬": 1.1,
|
35 |
+
"Butterfly π¦": 1.2
|
36 |
+
}
|
37 |
+
|
38 |
+
ring_style_factors = {
|
39 |
+
"Standard π": 1.0,
|
40 |
+
"Mixed Grip β¨": 1.1,
|
41 |
+
"Wide Grip π ": 1.2
|
42 |
+
}
|
43 |
+
|
44 |
st.sidebar.subheader("Choose Swim Style π")
|
45 |
swim_style = st.sidebar.selectbox(
|
46 |
"",
|
47 |
+
list(swim_style_factors.keys())
|
48 |
)
|
49 |
|
50 |
st.sidebar.subheader("Choose Ring Style πͺ")
|
51 |
ring_style = st.sidebar.selectbox(
|
52 |
"",
|
53 |
+
list(ring_style_factors.keys())
|
54 |
)
|
55 |
|
56 |
# Calculation
|
57 |
weight_kg = weight * 0.453592
|
58 |
+
calories_from_swimming = calories_swim(time_swim, weight_kg, swim_style_factors[swim_style])
|
59 |
+
calories_from_pullups = calories_pullup(weight, reps, ring_style_factors[ring_style])
|
60 |
|
61 |
# Display
|
62 |
st.subheader(f"Calories Burned π₯")
|