awacke1 commited on
Commit
46b19ef
Β·
1 Parent(s): 7b6e912

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -26
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, 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
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
- # 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(
27
  "",
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
  }
@@ -44,21 +48,21 @@ ring_style_factors = {
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 πŸ”₯")
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("Various swim styles focus on different muscle groups.")
81
 
82
- st.subheader(f"Ring Style: {ring_style} πŸͺ")
83
- st.write("Different grip styles can emphasize different muscle groups.")
 
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]}")