BMI_converter / app.py
Anum15's picture
Update app.py
d67c88a verified
raw
history blame contribute delete
977 Bytes
import streamlit as st
def get_height_in_meters(feet, inches):
total_inches = (feet * 12) + inches
height_in_meters = total_inches * 0.0254
return height_in_meters
def calculate_bmi(weight, height_m):
return weight / (height_m ** 2)
# Streamlit UI
st.title("BMI Converter App")
weight = st.number_input("Enter your weight (kg):", min_value=1.0, format="%.2f")
feet = st.number_input("Enter your height - Feet:", min_value=0, max_value=8, step=1)
inches = st.number_input("Enter your height - Inches:", min_value=0, max_value=11, step=1)
if st.button("Calculate BMI"):
height_m = get_height_in_meters(feet, inches)
bmi = calculate_bmi(weight, height_m)
st.write(f"### Your BMI is: {bmi:.2f}")
if bmi < 18.5:
st.warning("You are underweight.")
elif 18.5 <= bmi < 24.9:
st.success("You have a normal weight.")
elif 25 <= bmi < 29.9:
st.info("You are overweight.")
else:
st.error("You are obese.")