import streamlit as st st.title("BMI Calculator") # Input weight (kg) and height (cm) as integers via text input weight_input = st.text_input("Enter your weight (kg):", value="") height_input = st.text_input("Enter your height (cm):", value="") # Validate inputs and calculate BMI if st.button("Calculate BMI"): try: weight = int(weight_input) height = int(height_input) if weight <= 0 or height <= 0: st.error("Please enter positive integers for weight and height.") else: height_in_m = height / 100 # Convert cm to meters bmi = weight / (height_in_m ** 2) st.success(f"Your BMI: {bmi:.2f}") # BMI Categories 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") except ValueError: st.error("Please enter valid integer values for both fields.")