Create backup.app.py
Browse files- backup.app.py +85 -0
backup.app.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Function to calculate calories burned during swimming based on swim style, now in pounds
|
4 |
+
def calories_swim(time_hr, weight_lb, style_mets):
|
5 |
+
return (time_hr * style_mets * 3.5 * weight_lb) / 10
|
6 |
+
|
7 |
+
# Function to calculate calories burned during pull-ups based on grip style
|
8 |
+
def calories_pullup(reps, weight, grip_style_factor):
|
9 |
+
return (reps * 5 * weight) / 150 * grip_style_factor
|
10 |
+
|
11 |
+
# Streamlit UI
|
12 |
+
st.title("Calories Burned Calculator πββοΈπͺ")
|
13 |
+
st.sidebar.header("Input Parameters π οΈ")
|
14 |
+
|
15 |
+
# Swimming parameters
|
16 |
+
time_swim = st.sidebar.slider("Swimming Time (hours)", 0.0, 5.0, 2.0)
|
17 |
+
weight = st.sidebar.number_input("Your weight (lbs)", 100, 300, 175)
|
18 |
+
|
19 |
+
# Pull-Up parameters
|
20 |
+
reps = st.sidebar.slider("Number of Pull-Ups", 0, 500, 200)
|
21 |
+
|
22 |
+
# Choose Exercise Type
|
23 |
+
st.sidebar.subheader("Choose Exercise Type π€ΈββοΈ")
|
24 |
+
exercise_type = st.sidebar.selectbox(
|
25 |
+
"",
|
26 |
+
["Swim Jim πββοΈ", "Ring King π", "Both Boost π"]
|
27 |
+
)
|
28 |
+
|
29 |
+
# Revised Swim Styles with METs to meet your requirement
|
30 |
+
swim_styles = {
|
31 |
+
"Treading Water π": 6,
|
32 |
+
"Backstroke πββοΈ": 9,
|
33 |
+
"Breaststroke πΈ": 10,
|
34 |
+
"Freestyle Light π¦": 11,
|
35 |
+
"Freestyle Vigorous π": 14.3,
|
36 |
+
"Butterfly π¦": 14.3,
|
37 |
+
"Dog Paddle πΆ": 7
|
38 |
+
}
|
39 |
+
|
40 |
+
# Grip Styles with factors
|
41 |
+
grip_styles = {
|
42 |
+
"Standard π": 1,
|
43 |
+
"Mixed Grip β¨": 1.1,
|
44 |
+
"Wide Grip π ": 1.2
|
45 |
+
}
|
46 |
+
|
47 |
+
st.sidebar.subheader("Choose Swim Style π")
|
48 |
+
swim_style = st.sidebar.selectbox(
|
49 |
+
"",
|
50 |
+
list(swim_styles.keys())
|
51 |
+
)
|
52 |
+
|
53 |
+
st.sidebar.subheader("Choose Ring Style πͺ")
|
54 |
+
grip_style = st.sidebar.selectbox(
|
55 |
+
"",
|
56 |
+
list(grip_styles.keys())
|
57 |
+
)
|
58 |
+
|
59 |
+
# Calculation
|
60 |
+
calories_from_swimming = calories_swim(time_swim, weight, swim_styles[swim_style])
|
61 |
+
calories_from_pullups = calories_pullup(reps, weight, grip_styles[grip_style])
|
62 |
+
|
63 |
+
# Display Results
|
64 |
+
st.subheader(f"Calories Burned π₯")
|
65 |
+
if exercise_type == "Swim Jim πββοΈ":
|
66 |
+
st.write(f"Calories burned from swimming: {calories_from_swimming:.2f}")
|
67 |
+
elif exercise_type == "Ring King π":
|
68 |
+
st.write(f"Calories burned from pull-ups: {calories_from_pullups:.2f}")
|
69 |
+
else:
|
70 |
+
total_calories = calories_from_swimming + calories_from_pullups
|
71 |
+
st.write(f"Total calories burned: {total_calories:.2f}")
|
72 |
+
|
73 |
+
st.subheader("Muscle Groups Worked π¦Ύ")
|
74 |
+
if exercise_type == "Swim Jim πββοΈ":
|
75 |
+
st.write("Swimming works the back, shoulders, arms, and legs.")
|
76 |
+
elif exercise_type == "Ring King π":
|
77 |
+
st.write("Pull-ups work the back, biceps, and forearms.")
|
78 |
+
else:
|
79 |
+
st.write("Doing both exercises works almost all major muscle groups!")
|
80 |
+
|
81 |
+
st.subheader(f"Swim Style: {swim_style} π")
|
82 |
+
st.write(f"METS for chosen style: {swim_styles[swim_style]}")
|
83 |
+
|
84 |
+
st.subheader(f"Ring Style: {grip_style} πͺ")
|
85 |
+
st.write(f"Factor for chosen grip: {grip_styles[grip_style]}")
|