Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
# Function to calculate calories burned during swimming
|
4 |
-
def calories_swim(time_hr, weight_kg,
|
5 |
-
|
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(
|
10 |
-
#
|
11 |
-
|
12 |
-
return calories_per_pullup * reps
|
13 |
|
14 |
# Streamlit UI
|
15 |
st.title("Calories Burned Calculator πββοΈπͺ")
|
@@ -19,24 +17,30 @@ st.sidebar.header("Input Parameters π οΈ")
|
|
19 |
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 |
-
#
|
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(
|
27 |
"",
|
28 |
["Swim Jim πββοΈ", "Ring King π", "Both Boost π"]
|
29 |
)
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
"
|
34 |
-
"
|
35 |
-
"
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
-
|
39 |
-
|
|
|
40 |
"Mixed Grip β¨": 1.1,
|
41 |
"Wide Grip π ": 1.2
|
42 |
}
|
@@ -44,21 +48,21 @@ ring_style_factors = {
|
|
44 |
st.sidebar.subheader("Choose Swim Style π")
|
45 |
swim_style = st.sidebar.selectbox(
|
46 |
"",
|
47 |
-
list(
|
48 |
)
|
49 |
|
50 |
st.sidebar.subheader("Choose Ring Style πͺ")
|
51 |
-
|
52 |
"",
|
53 |
-
list(
|
54 |
)
|
55 |
|
56 |
# Calculation
|
57 |
weight_kg = weight * 0.453592
|
58 |
-
calories_from_swimming = calories_swim(time_swim, weight_kg,
|
59 |
-
calories_from_pullups = calories_pullup(
|
60 |
|
61 |
-
# Display
|
62 |
st.subheader(f"Calories Burned π₯")
|
63 |
if exercise_type == "Swim Jim πββοΈ":
|
64 |
st.write(f"Calories burned from swimming: {calories_from_swimming:.2f}")
|
@@ -77,7 +81,7 @@ else:
|
|
77 |
st.write("Doing both exercises works almost all major muscle groups!")
|
78 |
|
79 |
st.subheader(f"Swim Style: {swim_style} π")
|
80 |
-
st.write("
|
81 |
|
82 |
-
st.subheader(f"Ring Style: {
|
83 |
-
st.write("
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Function to calculate calories burned during swimming based on swim style
|
4 |
+
def calories_swim(time_hr, weight_kg, style_mets):
|
5 |
+
return (time_hr * style_mets * 3.5 * weight_kg) / 200
|
|
|
6 |
|
7 |
+
# Function to calculate calories burned during pull-ups based on grip style
|
8 |
+
def calories_pullup(reps, weight, grip_style_factor):
|
9 |
+
# Using formula PUC = (PU * 5 * BW / 150) * grip_style_factor
|
10 |
+
return (reps * 5 * weight) / 150 * grip_style_factor
|
|
|
11 |
|
12 |
# Streamlit UI
|
13 |
st.title("Calories Burned Calculator πββοΈπͺ")
|
|
|
17 |
time_swim = st.sidebar.slider("Swimming Time (hours)", 0.0, 5.0, 2.0)
|
18 |
weight = st.sidebar.number_input("Your weight (lbs)", 100, 300, 175)
|
19 |
|
20 |
+
# Pull-Up parameters
|
21 |
reps = st.sidebar.slider("Number of Pull-Ups", 0, 500, 200)
|
22 |
|
23 |
+
# Choose Exercise Type
|
24 |
st.sidebar.subheader("Choose Exercise Type π€ΈββοΈ")
|
25 |
exercise_type = st.sidebar.selectbox(
|
26 |
"",
|
27 |
["Swim Jim πββοΈ", "Ring King π", "Both Boost π"]
|
28 |
)
|
29 |
|
30 |
+
# Swim Styles with METs
|
31 |
+
swim_styles = {
|
32 |
+
"Treading Water π": 3.5,
|
33 |
+
"Backstroke πββοΈ": 4.8,
|
34 |
+
"Breaststroke πΈ": 5.3,
|
35 |
+
"Freestyle Light π¦": 5.8,
|
36 |
+
"Freestyle Vigorous π": 8.3,
|
37 |
+
"Butterfly π¦": 7.5,
|
38 |
+
"Dog Paddle πΆ": 4.0
|
39 |
}
|
40 |
|
41 |
+
# Grip Styles with factors
|
42 |
+
grip_styles = {
|
43 |
+
"Standard π": 1,
|
44 |
"Mixed Grip β¨": 1.1,
|
45 |
"Wide Grip π ": 1.2
|
46 |
}
|
|
|
48 |
st.sidebar.subheader("Choose Swim Style π")
|
49 |
swim_style = st.sidebar.selectbox(
|
50 |
"",
|
51 |
+
list(swim_styles.keys())
|
52 |
)
|
53 |
|
54 |
st.sidebar.subheader("Choose Ring Style πͺ")
|
55 |
+
grip_style = st.sidebar.selectbox(
|
56 |
"",
|
57 |
+
list(grip_styles.keys())
|
58 |
)
|
59 |
|
60 |
# Calculation
|
61 |
weight_kg = weight * 0.453592
|
62 |
+
calories_from_swimming = calories_swim(time_swim, weight_kg, swim_styles[swim_style])
|
63 |
+
calories_from_pullups = calories_pullup(reps, weight, grip_styles[grip_style])
|
64 |
|
65 |
+
# Display Results
|
66 |
st.subheader(f"Calories Burned π₯")
|
67 |
if exercise_type == "Swim Jim πββοΈ":
|
68 |
st.write(f"Calories burned from swimming: {calories_from_swimming:.2f}")
|
|
|
81 |
st.write("Doing both exercises works almost all major muscle groups!")
|
82 |
|
83 |
st.subheader(f"Swim Style: {swim_style} π")
|
84 |
+
st.write(f"METS for chosen style: {swim_styles[swim_style]}")
|
85 |
|
86 |
+
st.subheader(f"Ring Style: {grip_style} πͺ")
|
87 |
+
st.write(f"Factor for chosen grip: {grip_styles[grip_style]}")
|