Python: Calculate body mass index
Python Basic: Exercise-66 with Solution
BMI Calculator
Write a Python program to calculate the body mass index.
Pictorial Presentation:
Sample Solution:
Python Code:
# Prompt the user to input their height in feet and convert it to a floating-point number.
height = float(input("Input your height in Feet: "))
# Prompt the user to input their weight in kilograms and convert it to a floating-point number.
weight = float(input("Input your weight in Kilograms: "))
# Calculate the body mass index (BMI) using the provided height and weight and round it to 2 decimal places.
bmi = weight / (height * height)
rounded_bmi = round(bmi, 2)
# Print the calculated BMI.
print("Your body mass index is: ", rounded_bmi)
Sample Output:
Input your height in Feet: 6 Input your weight in Kilogram: 65 Your body mass index is: 1.81
Flowchart:
Python Code Editor:
Previous: Write a Python program to convert seconds to day, hour, minutes and seconds.
Next: Write a Python program to convert pressure in kilopascals to pounds per square inch,a millimeter of mercury (mmHg) and atmosphere pressure.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/python-exercises/python-basic-exercise-66.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics