Spaces:
Build error
Build error
Download src/streamlit_app.py from HugMeBytes/BMI_Calculator: direct link, hf CLI and curl.
- Browser
- Download file 591 Bytes
-
https://huggingface.co/spaces/HugMeBytes/BMI_Calculator/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/HugMeBytes/BMI_Calculator/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/HugMeBytes/BMI_Calculator/resolve/main/src/streamlit_app.py
591 Bytes
| import streamlit as st | |
| st.title("BMI Calculator") | |
| # Inputs | |
| weight = st.number_input("Enter your weight (kg):", min_value=1.0) | |
| height = st.number_input("Enter your height (cm):", min_value=1.0) | |
| if st.button("Calculate BMI"): | |
| height_in_m = height / 100 # convert cm to meters | |
| bmi = weight / (height_in_m ** 2) | |
| st.success(f"Your BMI: {bmi:.2f}") | |
| # Categorize BMI | |
| 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") | |