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.
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.
PART 1:
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.
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”.
OUTPUT :
The output of the code will look like this. I'm sharing multiple outputs based on different inputs producing different results.
Output # 01:-
Output # 02:-
HERE'S THE WHOLE CODE FROM START TO END:
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
@cryptokraze | @arie.steem | @qasimwaqar | @vvarishayy | @suboohi
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Okay okay, understood 👍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Interesting 👏
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks 😉
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit