Mtkhang90 commited on
Commit
7b07be4
·
verified ·
1 Parent(s): c297598

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -1,24 +1,29 @@
1
- st.title('BMI Calculator')
2
 
3
- # Input fields
4
- st.header('Enter your details:')
5
- weight = st.number_input('Weight (in kilograms)', min_value=0.0, format="%.2f")
6
- height = st.number_input('Height (in meters)', min_value=0.0, format="%.2f")
7
 
8
- # Calculate BMI
9
- if st.button('Calculate BMI'):
 
 
 
 
 
 
 
 
10
  if height > 0:
11
  bmi = weight / (height ** 2)
12
- st.success(f'Your BMI is {bmi:.2f}')
13
 
14
- # BMI Category
15
  if bmi < 18.5:
16
- st.info('You are underweight.')
17
  elif 18.5 <= bmi < 24.9:
18
- st.success('You have a normal weight.')
19
  elif 25 <= bmi < 29.9:
20
- st.warning('You are overweight.')
21
  else:
22
- st.error('You are obese.')
23
  else:
24
- st.error('Height must be greater than 0.')
 
1
+ import streamlit as st
2
 
3
+ st.set_page_config(page_title="BMI Calculator", page_icon="💪", layout="centered")
 
 
 
4
 
5
+ st.title('💪 BMI Calculator')
6
+
7
+ st.write('Calculate your Body Mass Index (BMI) easily!')
8
+
9
+ # Input
10
+ weight = st.number_input('Enter your weight (kg)', min_value=1.0, step=0.5)
11
+ height = st.number_input('Enter your height (meters)', min_value=0.1, step=0.01)
12
+
13
+ # Calculate
14
+ if st.button('Calculate'):
15
  if height > 0:
16
  bmi = weight / (height ** 2)
17
+ st.success(f'Your BMI is: {bmi:.2f}')
18
 
19
+ # Category
20
  if bmi < 18.5:
21
+ st.info('You are Underweight.')
22
  elif 18.5 <= bmi < 24.9:
23
+ st.success('You have Normal weight.')
24
  elif 25 <= bmi < 29.9:
25
+ st.warning('You are Overweight.')
26
  else:
27
+ st.error('You are Obese.')
28
  else:
29
+ st.error('Height must be greater than zero.')