|
1 | 1 | # BMI calculator
|
| 2 | +# Instructions |
| 3 | +# Write a program that interprets the Body Mass Index (BMI) based on a user's weight and height. |
2 | 4 |
|
3 |
| -# Taking user input for height |
4 |
| -height = input("Enter you height in m: ") |
5 |
| -weight = input("Enter your wight in kg: ") |
| 5 | +# It should tell them the interpretation of their BMI based on the BMI value. |
| 6 | + |
| 7 | +# Under 18.5 they are underweight |
| 8 | +# Over 18.5 but below 25 they have a normal weight |
| 9 | +# Over 25 but below 30 they are slightly overweight |
| 10 | +# Over 30 but below 35 they are obese |
| 11 | +# Above 35 they are clinically obese. |
| 12 | + |
| 13 | +# Solution |
6 | 14 |
|
7 |
| -# converting strings to number |
| 15 | +# Taking user input for height |
| 16 | +height = float(input("Enter you height in m: ")) |
| 17 | +weight = float(input("Enter your wight in kg: ")) |
8 | 18 |
|
9 |
| -weight_as_int = int(weight) |
10 |
| -height_as_float = float(height) |
11 | 19 |
|
12 | 20 | # calculate the bmi value
|
13 |
| -bmi = weight_as_int / (height_as_float ** 2) |
| 21 | +bmi = round(weight / height ** 2) |
| 22 | + |
| 23 | +# Checking the condition for BMI Value |
| 24 | +if bmi < 18.5: |
| 25 | + print(f"Your BMI {bmi}, you are underweight") |
| 26 | +elif bmi < 25: |
| 27 | + print(f"Your BMI {bmi}, you are normal weight") |
| 28 | +elif bmi < 30: |
| 29 | + print(f"Your BMI {bmi}, You are slightly overweight") |
| 30 | +elif bmi < 35: |
| 31 | + print(f"Your BMI {bmi}, You are obese") |
| 32 | +else: |
| 33 | + print(f"Your BMI {bmi}, You are clinically obese") |
| 34 | + |
14 | 35 |
|
15 |
| -# print(int(bmi)) |
16 |
| -print(f"Your BMI Value is: {int(bmi)}") |
|
0 commit comments