mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-30 15:31:07 +00:00
add a small streamlit application
This commit is contained in:
parent
f0ea440d41
commit
b8772f514c
52
BMI_and_BMR_Calculator/1_Home.py
Normal file
52
BMI_and_BMR_Calculator/1_Home.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
import streamlit as st
|
||||
import pandas as pd
|
||||
from pathlib import Path
|
||||
import pickle
|
||||
|
||||
|
||||
layout ='centered'
|
||||
page_title = 'BMI and BMR Calculator'
|
||||
|
||||
st.set_page_config(page_title=page_title, layout=layout)
|
||||
st.header(page_title)
|
||||
|
||||
st.subheader('Body Mass Index (BMI)')
|
||||
|
||||
st.write('''BMI is a measurement of a person's leanness
|
||||
or corpulence based on their height and weight, and
|
||||
is intended to quantify tissue mass.
|
||||
It is widely used as a general indicator of whether a person has a healthy body weight for their height. Specifically, the value obtained from the calculation of BMI is used to categorize whether a person is underweight, normal weight, overweight, or obese depending on what range the value falls between. These ranges of BMI vary based on factors such as region and age, and are sometimes further divided into subcategories such as severely underweight or very severely obese. Being overweight or underweight can have significant health effects, so while BMI is an imperfect measure of healthy body weight, it is a useful indicator of
|
||||
whether any additional testing or action is required''')
|
||||
|
||||
|
||||
st.subheader('BMI Formula')
|
||||
st.write('''
|
||||
BMI in the International System of Units (SI)\n\n
|
||||
\t\t\t BMI = Mass(Kg)/(Height(m)^2)
|
||||
''')
|
||||
|
||||
|
||||
|
||||
|
||||
st.subheader('Basal Metabolic Rate (BMR)')
|
||||
|
||||
st.write('''
|
||||
The basal metabolic rate (BMR) is the amount of energy needed while resting in
|
||||
a temperate environment when the digestive system is inactive. It is the
|
||||
equivalent of figuring out how much gas an idle car consumes while parked.
|
||||
In such a state, energy will be used only to maintain vital organs, which
|
||||
include the heart, brain, kidneys, nervous system, intestines, liver, lungs,
|
||||
sex organs, muscles, and skin.
|
||||
''')
|
||||
|
||||
st.write('''
|
||||
\n Mifflin-St Jeor Equation:\n
|
||||
\nFor men: BMR = 10W + 6.25H - 5A + 5\n
|
||||
For women: BMR = 10W + 6.25H - 5A - 161
|
||||
''')
|
||||
|
||||
|
||||
|
||||
st.write("\n\nTo measure your BMI and BMR go to the calculate page\n")
|
||||
|
||||
|
32
BMI_and_BMR_Calculator/README.md
Normal file
32
BMI_and_BMR_Calculator/README.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
# BMI and BMR Calculator
|
||||
|
||||
This Streamlit application calculates BMI and BMR for adults. Users input their height, weight, age, and gender to get their BMI, BMR, and a short analysis of their weight category, including insights on whether they are underweight, normal weight, overweight, or obese.
|
||||
|
||||
|
||||
## Run the application
|
||||
|
||||
Download the repo
|
||||
|
||||
```bash
|
||||
git clone https://github.com/gitarshmah/Awesome-Python-Scripts.git
|
||||
```
|
||||
|
||||
Go to the project directory
|
||||
|
||||
```bash
|
||||
cd BMI_and_BMR_Calculator/
|
||||
```
|
||||
|
||||
Install Streamlit
|
||||
|
||||
```bash
|
||||
pip install streamlit
|
||||
```
|
||||
|
||||
Run the app
|
||||
|
||||
```bash
|
||||
streamlit run 1_Home.py
|
||||
```
|
||||
|
66
BMI_and_BMR_Calculator/pages/2_Calculate.py
Normal file
66
BMI_and_BMR_Calculator/pages/2_Calculate.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
import streamlit as st
|
||||
|
||||
st.subheader('Calculate BMI(Body Mass Index) \n\n')
|
||||
st.write("Have a look at the chart displaying the different BMI ranges according to their respective weight categories.\n\n")
|
||||
st.image('ranges.png')
|
||||
|
||||
height = st.number_input("Enter your height in(cms): ", min_value=100)
|
||||
weight = st.number_input("Enter your weight in kgs: ", min_value=1)
|
||||
def bmi(height, weight):
|
||||
value = weight/((height/100)**2)
|
||||
return value*(1.0)
|
||||
def category(person_bmi):
|
||||
if person_bmi<16:
|
||||
return ("Severe Thinness")
|
||||
elif person_bmi>=16 and person_bmi<17:
|
||||
return ("Moderate Thinness")
|
||||
elif person_bmi>=17 and person_bmi<18.5:
|
||||
return ("Mild Thinness")
|
||||
|
||||
elif person_bmi>=18.5 and person_bmi<25:
|
||||
return ("Normal")
|
||||
|
||||
|
||||
elif person_bmi>=25 and person_bmi<30:
|
||||
return ("Overweight")
|
||||
|
||||
|
||||
elif person_bmi>=30 and person_bmi<35:
|
||||
return ("Obese Class I")
|
||||
|
||||
elif person_bmi>=35 and person_bmi<40:
|
||||
return ("Obese Class II")
|
||||
|
||||
else:
|
||||
return ("Obese Class III")
|
||||
|
||||
|
||||
person_bmi = bmi(height, weight)
|
||||
st.write("Your BMI is "+str(person_bmi)+' kg/m2')
|
||||
st.write("You lies under the category of " + category(person_bmi))
|
||||
|
||||
|
||||
st.subheader('\n\nCalculate BMR(Basal Metabolic Rate)\n\n')
|
||||
age = st.number_input("Enter your age: ")
|
||||
gender = st.text_input("Enter your gender Either('M' or 'F'): ")
|
||||
if gender == 'M':
|
||||
bmr = (10 * weight) + (6.25 * height) - (5 * age) + 5
|
||||
else:
|
||||
bmr = (10 * weight) + (6.25 * height) - (5 * age) - 161
|
||||
|
||||
lifestyle = st.selectbox('Choose the lifestyle', options=['sedentary (little or no exercise)', 'lightly active (light exercise or sports 1-3 days/week)', 'moderately active (moderate exercise 3-5 days/week)', 'very active (hard exercise 6-7 days/week)','super active (very hard exercise and a physical job)'])
|
||||
|
||||
if lifestyle == 'sedentary (little or no exercise)':
|
||||
bmr = bmr*1.2
|
||||
elif lifestyle == 'lightly active (light exercise or sports 1-3 days/week)':
|
||||
bmr = bmr*1.375
|
||||
elif lifestyle == 'moderately active (moderate exercise 3-5 days/week)':
|
||||
bmr = bmr*1.55
|
||||
elif lifestyle == 'very active (hard exercise 6-7 days/week)':
|
||||
bmr = bmr*1.725
|
||||
else:
|
||||
bmr =bmr*1.9
|
||||
|
||||
st.text(f'Your daily calories consumption is {bmr} kcal per day')
|
||||
|
||||
|
BIN
BMI_and_BMR_Calculator/ranges.png
Normal file
BIN
BMI_and_BMR_Calculator/ranges.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
Loading…
Reference in New Issue
Block a user