Introduction
In this post, you will learn how to make the BMI calculator in python and also I will teach every piece of code and what it does and below is the video format of the post, check it out ????????
Video:
What is BMI calculator
BMI stands for “Body mass index“, and these BMI calculators will be helpful for keeping health properly and to find you are underweight, overweight, healthy or fat.
Below is the chart for the BMI calculator ????????
BMI Calculator python code
Below is the BMI calculator python code,
height = input(“Please enter your height in meter: “)
weight = input(“Please enter your weight in kg: “)
The height and weight will be get from the user using the input function and you know very well the BMI = weight / height ** 2
You need to use this formula ☝
Now if you just print the result you won’t get the result instead you get an error. Like this ????????
This is because the str and int are together as I said in the previous post the str and int will not be together.
So, what I am doing is specifying the data type, like this ????????
Once, I added the data types and again I am doing a type conversion and changing the value int. So, I get the values in whole numbers.
Now, if I run the code the result will be looking something like this ????????????
So, Finally, we have successfully created the BMI calculator in python and if you have any doubts or if you got any errors comment down below, I will answer in 12 hrs.
If you wanted to print the result in a good and meaningful format then enter this code that is the, .format
So, this is how to make the result in a more meaningful format. See you in next post ????
Also Read: Type function in python
Also Read: Arithmetic operators in python