Answer to Question #320885 in Python for leigh

Question #320885

BMI


Take in the


Mass Height


Print out which bmi class the user is in



1
Expert's answer
2022-04-01T05:25:59-0400
def BMI(mass, height):
    return mass/height**2


def category(bmi):
    descrip = ['Severe Thiness', 'Moderate Thinness', 'Mild Thinness',
         'Normal', 'Overweight', 'Obese Class I',
         'Obese Class II', 'Obese Class III']
    if bmi < 16:
        idx = 0
    elif bmi < 17:
        idx = 1
    elif bmi < 18.5:
        idx = 2
    elif bmi < 25:
        idx = 3
    elif bmi < 30:
        idx = 4
    elif bmi < 35:
        idx = 5
    elif bmi < 40:
        idx = 6
    else:
        idx = 7
    return descrip[idx]


def main():
    mass = float(input('Input your mass (in kg): '))
    height = float(input('Input your height (in m): '))
    bmi = BMI(mass, height)
    descrip = category(bmi)
    print(f'Your BMI is {bmi:.1f} and you are {descrip} according to the WHO')


if __name__ == '__main__':
    main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS