Spaces:
Build error
Build error
File size: 591 Bytes
50fd806 579a223 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import streamlit as st
st.title("BMI Calculator")
# Inputs
weight = st.number_input("Enter your weight (kg):", min_value=1.0)
height = st.number_input("Enter your height (cm):", min_value=1.0)
if st.button("Calculate BMI"):
height_in_m = height / 100 # convert cm to meters
bmi = weight / (height_in_m ** 2)
st.success(f"Your BMI: {bmi:.2f}")
# Categorize BMI
if bmi < 18.5:
st.warning("Underweight")
elif 18.5 <= bmi < 25:
st.success("Normal weight")
elif 25 <= bmi < 30:
st.warning("Overweight")
else:
st.error("Obese")
|