MuhammadSajid commited on
Commit
6332c45
·
verified ·
1 Parent(s): 99a78bc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("🏋️‍♂️ BMI Calculator")
4
+
5
+ # User inputs
6
+ st.subheader("Enter your height:")
7
+ feet = st.number_input("Feet", min_value=0, value=5)
8
+ inches = st.number_input("Inches", min_value=0, max_value=11, value=7)
9
+ weight = st.number_input("Enter your weight (kg)", min_value=0.0, value=70.0)
10
+
11
+ # BMI Calculation
12
+ if st.button("Calculate BMI"):
13
+ total_inches = (feet * 12) + inches
14
+ height_m = total_inches * 0.0254 # Convert height to meters
15
+ if height_m > 0:
16
+ bmi = weight / (height_m ** 2)
17
+ st.success(f"Your BMI is: {bmi:.2f}")
18
+
19
+ # BMI Categories
20
+ if bmi < 18.5:
21
+ st.info("Category: Underweight")
22
+ elif 18.5 <= bmi < 24.9:
23
+ st.success("Category: Normal weight")
24
+ elif 25 <= bmi < 29.9:
25
+ st.warning("Category: Overweight")
26
+ else:
27
+ st.error("Category: Obese")
28
+ else:
29
+ st.error("Invalid height. Please check your input.")