In: Computer Science
how do you create a list in python to calculate BMI, if you were to want variables like height, weight, BMI, and classification in the list
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
# Take a list
classification = ['under weight', 'normal', 'over weight', 'obesity','severe obesity']
# Ask for values
weight = float(input('Enter weight in kg : '))
height = float(input('Enter height in cm : '))
# convert height to meters
height = height/100
# calculate bmi value
bmi = weight / (height * height)
# check the class and assign the value
if bmi < 18.5:
    weight_class = classification[0]
elif bmi < 24.9:
    weight_class = classification[1]
elif bmi < 29.9:
    weight_class = classification[2]
elif bmi<34.9:
    weight_class = classification[3]
else:
    weight_class=classification[4]
# print the output
print('Your BMI is', bmi, ' and weight class is: ', weight_class)
======
SAMPLE RUNS:



