Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,40 +1,47 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
st.
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
height
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
elif status == 'feet':
|
| 19 |
-
height = st.number_input('Enter height in Feet', min_value=0.0, step=0.1)
|
| 20 |
-
height /= 3.281 # Convert to meters
|
| 21 |
-
|
| 22 |
-
# BMI Calculation and Display
|
| 23 |
-
if st.button('Calculate BMI'):
|
| 24 |
-
if height > 0:
|
| 25 |
bmi = weight / (height ** 2)
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Welcome to BMI Calculator')
|
| 4 |
+
|
| 5 |
+
weight = st.number_input("Enter your weight (in kgs)")
|
| 6 |
|
| 7 |
+
status = st.radio('Select your height format: ',
|
| 8 |
+
('cms', 'meters', 'feet'))
|
| 9 |
+
|
| 10 |
+
if(status == 'cms'):
|
| 11 |
+
height = st.number_input('Centimeters')
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
bmi = weight / ((height/100)**2)
|
| 15 |
+
except:
|
| 16 |
+
st.text("Enter some value of height")
|
| 17 |
+
|
| 18 |
+
elif(status == 'meters'):
|
| 19 |
+
height = st.number_input('Meters')
|
| 20 |
+
|
| 21 |
+
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
bmi = weight / (height ** 2)
|
| 23 |
+
except:
|
| 24 |
+
st.text("Enter some value of height")
|
| 25 |
+
|
| 26 |
+
else:
|
| 27 |
+
height = st.number_input('Feet')
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
bmi = weight / (((height/3.28))**2)
|
| 31 |
+
except:
|
| 32 |
+
st.text("Enter some value of height")
|
| 33 |
+
|
| 34 |
+
if(st.button('Calculate BMI')):
|
| 35 |
+
|
| 36 |
+
st.text("Your BMI Index is {}.".format(bmi))
|
| 37 |
+
|
| 38 |
+
if(bmi < 16):
|
| 39 |
+
st.error("You are Extremely Underweight")
|
| 40 |
+
elif(bmi >= 16 and bmi < 18.5):
|
| 41 |
+
st.warning("You are Underweight")
|
| 42 |
+
elif(bmi >= 18.5 and bmi < 25):
|
| 43 |
+
st.success("Healthy")
|
| 44 |
+
elif(bmi >= 25 and bmi < 30):
|
| 45 |
+
st.warning("Overweight")
|
| 46 |
+
elif(bmi >= 30):
|
| 47 |
+
st.error("Extremely Overweight")
|