File size: 1,041 Bytes
d6d9133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st

# Title of the app
st.title("BMI Calculator")

# Description
st.write("Calculate your Body Mass Index (BMI) by entering your weight and height.")

# Input fields
weight = st.number_input("Enter your weight (kg):", min_value=0.0, value=70.0)
height = st.number_input("Enter your height (cm):", min_value=0.0, value=170.0)

# Calculate BMI
if st.button("Calculate BMI"):
    if height <= 0 or weight <= 0:
        st.error("Weight and height must be positive numbers.")
    else:
        bmi = weight / ((height / 100) ** 2)  # BMI formula
        bmi = round(bmi, 2)
        # Categorize BMI
        if bmi < 18.5:
            category = "Underweight"
        elif 18.5 <= bmi < 24.9:
            category = "Normal weight"
        elif 25 <= bmi < 29.9:
            category = "Overweight"
        else:
            category = "Obesity"
        st.success(f"Your BMI is **{bmi}** ({category}).")

# Display BMI Chart
st.write("### BMI Chart")
st.image("bmi_chart.jpg", caption="BMI Categories", use_column_width=True)