Initial work
This commit is contained in:
20
CS1032/practical-2023-10-18/fn2.py
Normal file
20
CS1032/practical-2023-10-18/fn2.py
Normal file
@@ -0,0 +1,20 @@
|
||||
def bmi(weight, height):
|
||||
return weight * height ** -2
|
||||
|
||||
def bmi_category(bmi):
|
||||
if bmi < 18.5:
|
||||
return "underweight"
|
||||
elif bmi < 25:
|
||||
return "healthy"
|
||||
elif bmi < 30:
|
||||
return "overweight"
|
||||
elif bmi < 40:
|
||||
return "obese"
|
||||
else:
|
||||
return "severely obese"
|
||||
|
||||
weight = float(input("Weight? "))
|
||||
height = float(input("Height? "))
|
||||
bmi = bmi(weight, height)
|
||||
print(f"BMI is {bmi:.3}")
|
||||
print(f"The BMI is in the {bmi_category(bmi)} category")
|
||||
Reference in New Issue
Block a user