Welcome to the Blog !! Today we will learn to build our own BMI (Body Mass Index) calculator which will help us to decide our BMI Category (Underweight , Normal Weight or Overweight).
✅ Problem Statement :
Mrs. Roy is very conscious about health and fitness. She regularly calculates BMI (Body Mass Index) in order to stay fit. But she hates calculations. So our job is to find simplify her task.
🔴 Formula to Calculate BMI :
BMI = (weight)/(height*height)
🔴 BMI Categories :
- Underweight - If BMI <=18.5
- Normal Weight - If BMI is in between 18.6 - 24.9
- Overweight - If BMI is >=25
✅ Concepts Covered in this Post :
- if..else statement
- input() function
- print() function
- round() function
📑Let's Code :)
Step 1 : Create new Python project and start writing code to build BMI Calculator.
We need to take 2 parameters as an input
- Weight (in kg)
- Height (in cm)
Step 2 : After taking input , we need to convert height in centimeter to meter.
So divide let's divide height(in cm) by 100.
Calculate BMI using this formula : BMI = (weight)/(height*height)
Refer below sample code for BMI Calculator :
Here we have used round() function to round off calculated BMI upto 2 decimals.
Step 3 : Let's run our code :)
Below is the sample output of the above code 👇👇
Hope you like this post 😉
You can reach us by entering your details in Contact Us box in the side panel💬
All the Best 👍👍👍👍
Happy Learning 😇😇😇
Source Code By :
Aditya Singh
(Guest Writer)
Wanted to be our Next Guest Writer ? You are just one DM away 😉 . Reach out to us on our Instagram handle or fill contact us form !