Mtkhang90's picture
Update app.py
7b07be4 verified
raw
history blame contribute delete
879 Bytes
import streamlit as st
st.set_page_config(page_title="BMI Calculator", page_icon="💪", layout="centered")
st.title('💪 BMI Calculator')
st.write('Calculate your Body Mass Index (BMI) easily!')
# Input
weight = st.number_input('Enter your weight (kg)', min_value=1.0, step=0.5)
height = st.number_input('Enter your height (meters)', min_value=0.1, step=0.01)
# Calculate
if st.button('Calculate'):
if height > 0:
bmi = weight / (height ** 2)
st.success(f'Your BMI is: {bmi:.2f}')
# Category
if bmi < 18.5:
st.info('You are Underweight.')
elif 18.5 <= bmi < 24.9:
st.success('You have Normal weight.')
elif 25 <= bmi < 29.9:
st.warning('You are Overweight.')
else:
st.error('You are Obese.')
else:
st.error('Height must be greater than zero.')