Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
st.title('Welcome to the BMI Calculator')
|
| 3 |
+
|
| 4 |
+
weight = st.number_input('Enter your weight in Kgs')
|
| 5 |
+
status = st.radio('Select your height format:',('cms','meters','feet'))
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
if status == 'cms':
|
| 9 |
+
height = st.number_input('Centimeters')
|
| 10 |
+
bmi = weight/((height/100)**2)
|
| 11 |
+
|
| 12 |
+
elif status == 'meters':
|
| 13 |
+
height = st.number_input('meters')
|
| 14 |
+
bmi = weight/((height)**2)
|
| 15 |
+
|
| 16 |
+
elif status == 'feet':
|
| 17 |
+
height = st.number_input('feet')
|
| 18 |
+
bmi = weight/((height/3.28)**2)
|
| 19 |
+
except:
|
| 20 |
+
print('Zero Division error')
|
| 21 |
+
|
| 22 |
+
if st.button('Calculate BMI'):
|
| 23 |
+
st.write('Your BMI Index is {}.'.format(round(bmi)))
|
| 24 |
+
|
| 25 |
+
if bmi<16:
|
| 26 |
+
st.error('You are extremely underweight')
|
| 27 |
+
elif (bmi>=16 and bmi<18):
|
| 28 |
+
st.warning('You are underweight')
|
| 29 |
+
elif (bmi>=18 and bmi<25):
|
| 30 |
+
st.success('You are Healhy')
|
| 31 |
+
elif (bmi>=25 and bmi<30):
|
| 32 |
+
st.warning('You are Overweight')
|
| 33 |
+
elif bmi>=30:
|
| 34 |
+
st.error('Extremely overweight')
|