SIZ Tutorial | Body Mass Index Calculator in Python | 20% to @siz-official | by @uzair5

in Steem Infinity Zone3 years ago

Hello @Steemit fellows! Hope you are doing well.
It me, Uzair Rehman and I would like to share python code of how to create a Body Mass Index (BMI) calculator. BMI is a measure of relative weight based on an individual’s mass and height and it is calculated from weight and height of a person.

BMI-Calculator-with-Python.png
source

What's the purpose of BMI calculator ?

Body Mass Index is commonly used to classify people as underweight, overweight , and even with obesity. It is adopted by countries to promote healthy eating.

Divider 2.png

PART 1:

bmi1.png

I've created a function so we can use this function later in our code, and in this function I've described what’s the formula to calculate body mass index (bmi).


PART 2:

In this step, first we’ve taken the input from the user of his/her height and weight in cm and kg units respectively. Then next two lines are for display user’s data that he/she entered. In 5th line of this part, we’ve called BMI function, that we’ve created earlier. & last line code is to display health chart.

bmi2.png


PART 3:

In this step, we’ve used conditional statement (if, else & elif) to find out BMI category.
• If BMI result is less than 18.49, then it’ll classify people as underweight.
• If BMI result is greater than or equal to 18.5 and less 24.9, then it’ll classify people as healthy.
• If BMI result is greater than or equal to 25 and less 29.9, then it’ll classify people as overweight.
• If BMI result is greater than or equal to 30 and less 34.9, then it’ll classify people as obesity(class 1).
• If BMI result is greater than or equal to 35 and less 39.9, then it’ll classify people as obesity(class 2).
• If BMI result is greater than or equal to 40, then it’ll classify people as obesity(class 3).
• BMI result must be greater than 0, if BMI result is negative, then it’ll show error “Enter valid details”.

bmi3.png

Divider 2.png

OUTPUT :

The output of the code will look like this. I'm sharing multiple outputs based on different inputs producing different results.

Output # 01:-

result02.png

Output # 02:-

result01.png

Divider 2.png

HERE'S THE WHOLE CODE FROM START TO END:

WHOLECODE.png

Divider 2.png

That's it for my post. This code took hours of effort, so please consider supporting it. Also, let me know in the comments what other coding tutorials you'd like to see.


Note: I've explained this code step by step and attached the whole code to the end of the article so you easily copy or use it.


THANKS

Divider 2.png

Steem Infinity Zone Team
@cryptokraze | @arie.steem | @qasimwaqar | @vvarishayy | @suboohi

Footer.png

Click Here to Join Official SIZ Discord Channel

Discord
Twitter
Facebook

Divider 2.png

Sort:  
 3 years ago (edited)

Please read these guidelines.

You cannot post Tutorials.

You can apply for course and after approval you can post such tutorials in form of a course.

https://steemit.com/hive-181430/@siz-official/siz-community-guidelines-on-daily-content-creation-categories

Okay okay, understood 👍

Interesting 👏

Thanks 😉

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 58906.05
ETH 2666.51
USDT 1.00
SBD 2.44