Skip to content

Commit b5738f7

Browse files
committed
BMI calculator complete
1 parent 084656e commit b5738f7

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

bmi.py

+28-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
# BMI calculator
2+
# Instructions
3+
# Write a program that interprets the Body Mass Index (BMI) based on a user's weight and height.
24

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
614

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: "))
818

9-
weight_as_int = int(weight)
10-
height_as_float = float(height)
1119

1220
# 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+
1435

15-
# print(int(bmi))
16-
print(f"Your BMI Value is: {int(bmi)}")

0 commit comments

Comments
 (0)