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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -11
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
- # 1 calorie per 2.20462 pounds lifted per meter (estimated)
11
- calories_per_pullup = (weight * 0.453592) * 2 / 2.20462
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, 400)
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
- ["Frog Kick 🐸", "Dolphin Kick 🐬", "Butterfly πŸ¦‹"]
35
  )
36
 
37
  st.sidebar.subheader("Choose Ring Style πŸͺ")
38
  ring_style = st.sidebar.selectbox(
39
  "",
40
- ["Standard 🌟", "Mixed Grip ✨", "Wide Grip 🌠"]
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 πŸ”₯")