top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

BMI project

Writer's picture: Mohamed ElshamyMohamed Elshamy


A BMI Calculator will take in the height and weight of the individual and will calculate the BMI of the person.

Body mass index (BMI) is a measure of body fat based on height and weight.

Based on the BMI of the individual, it will print a statement stating the overall health of the person.

Let's start coding our project!

Let's Code

Alright, so the first thing we need to do is to ask the user their height & weight. This can be easily achieved through input() function

height = float(input("Enter your height in cm: "))weight = float(input("Enter your weight in kg: "))

We will convert the input string to float so that we can perform calculations with it.

Next up, we have to calculate the BMI.

The formula to calculate BMI is $weight (kg)/{height (m)}^2$. Let's implement this formula in python.

BMI = weight / (height/100)**2

Here we will be dividing the height by 100 to convert the centimetres into meters.

Now let's print out the BMI.

print(f"You BMI is {BMI}")

Now we have to print a statement to state the current health of the user based on their BMI

1 comment

Recent Posts

See All

1 Comment


Data Insight
Data Insight
Sep 23, 2021

Check other articles to see how to write a blog post.

Like
bottom of page