Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718192021222324252627import streamlit as stst.title("BMI Calculator")weight = st.number_input("Enter your weight (kg):", min_value=1.0, format="%.2f")height_unit = st.selectbox("Select height unit:", ["Centimeters", "Meters", "Feet"])height = st.number_input("Enter your height:", min_value=1.0, format="%.2f")if height_unit == "Centimeters":height = height / 100elif height_unit == "Feet":height = height * 0.3048if height > 0:bmi = weight / (height ** 2)st.write(f"### Your BMI: {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.warning("You are overweight.")else:st.error("You are in the obese category.")else:st.error("Please enter a valid height.")12345678910111213141516171819202122232425262728293031323334353637383940import streamlit as stst.title("BMI Calculator App")# Input weightweight = st.number_input("Enter your weight (in kgs)", min_value=0.0, step=0.1)# Select height formatstatus = st.radio('Select your height format:', ('cms', 'meters', 'feet'))# Input height based on selectionheight = 0if status == 'cms':height = st.number_input('Enter height in Centimeters', min_value=0.0, step=0.1)height /= 100 # Convert to meterselif status == 'meters':height = st.number_input('Enter height in Meters', min_value=0.0, step=0.01)elif status == 'feet':height = st.number_input('Enter height in Feet', min_value=0.0, step=0.1)height /= 3.281 # Convert to meters# BMI Calculation and Displayif st.button('Calculate BMI'):if height > 0:bmi = weight / (height ** 2)st.text(f"Your BMI Index is {bmi:.2f}.")# Categorizing BMIif bmi < 16:st.error("You are Extremely Underweight")elif 16 <= bmi < 18.5:st.warning("You are Underweight")elif 18.5 <= bmi < 25:st.success("You are Healthy")elif 25 <= bmi < 30:st.warning("You are Overweight")else:st.error("You are Extremely Overweight")else:st.error("Please enter a valid height greater than 0.")
app.py+34-21