Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +35 -40
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,35 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
x=alt.X("x", axis=None),
|
| 37 |
-
y=alt.Y("y", axis=None),
|
| 38 |
-
color=alt.Color("idx", legend=None, scale=alt.Scale()),
|
| 39 |
-
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
|
| 40 |
-
))
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title('Welcome to the BMI Calculator')
|
| 4 |
+
|
| 5 |
+
weight = st.number_input('Enter your weight in Kgs')
|
| 6 |
+
status = st.radio('Select your height format:',('cms','meters','feet'))
|
| 7 |
+
|
| 8 |
+
try:
|
| 9 |
+
if status == 'cms':
|
| 10 |
+
height = st.number_input('Centimeters')
|
| 11 |
+
bmi = weight/((height/100)**2)
|
| 12 |
+
|
| 13 |
+
elif status == 'meters':
|
| 14 |
+
height = st.number_input('meters')
|
| 15 |
+
bmi = weight/((height)**2)
|
| 16 |
+
|
| 17 |
+
elif status == 'feet':
|
| 18 |
+
height = st.number_input('feet')
|
| 19 |
+
bmi = weight/((height/3.28)**2)
|
| 20 |
+
except:
|
| 21 |
+
print('Zero Division Error')
|
| 22 |
+
|
| 23 |
+
if (st.button('Calculate BMI')):
|
| 24 |
+
st.write('Your BMI index is {}.'.format(round(bmi)))
|
| 25 |
+
|
| 26 |
+
if (bmi<16):
|
| 27 |
+
st.error('You are extremely Underweight')
|
| 28 |
+
elif (bmi >=16 and bmi<18.5):
|
| 29 |
+
st.warning('You are Underweight')
|
| 30 |
+
elif (bmi>=18.5 and bmi<25):
|
| 31 |
+
st.success('Healthy')
|
| 32 |
+
elif (bmi>=25 and bmi<30):
|
| 33 |
+
st.warning('Overweight')
|
| 34 |
+
elif (bmi>=30):
|
| 35 |
+
st.error('Extremely overweight')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|