day 3-4 (BMI 2.0 Exercise)
2023. 2. 22. 08:09ㆍ개인적인 공부/Python
BMI수치에 따른 해석문
Instructions
Write a program that interprets the Body Mass Index (BMI) based on a user's weight and height.
It should tell them the interpretation of their BMI based on the BMI value.
- Under 18.5 they are underweight : 18.5 아래 이면 저체중
- Over 18.5 but below 25 they have a normal weight : 18.5이상 25 미만 정상체중
- Over 25 but below 30 they are slightly overweight : 25이상 30미만 과체중
- Over 30 but below 35 they are obese : 30이상 35 미만 비만
- Above 35 they are clinically obese. : 35이상 대사증후군을 의심해보자
Warning you should round the result to the nearest whole number. The interpretation message needs to include the words in bold from the interpretations above. e.g. underweight, normal weight, overweight, obese, clinically obese.
Example Input
weight = 85
height = 1.75
Example Output
85 ÷ (1.75 x 1.75) = 27.755102040816325
Your BMI is 28, you are slightly overweight.
e.g. When you hit run, this is what should happen:
나의 코드
# 🚨 Don't change the code below 👇
height = input("enter your height in m: ")
weight = input("enter your weight in kg: ")
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
new_weight = float(weight)
new_height = float(height)
BMI = round(new_weight/(new_height**2))
result = BMI
if result < 18.5:
print(f"Your BMI is {result}, you are underweight.")
elif result < 25:
print(f"Your BMI is {result}, you have a normalweight.")
elif result < 30:
print(f"Your BMI is {result}, you are slightly overweight.")
elif result < 35:
print(f"Your BMI is {result}, you are obese")
else:
print(f"Your BMI is{result}, you are clinically obese")
'개인적인 공부 > Python' 카테고리의 다른 글
day 3-6 python (다중 연속 if 문) (0) | 2023.02.22 |
---|---|
day 3-5 python (윤년, Leap Year) (0) | 2023.02.22 |
day3-3 python (중첩 if 문과 elif문) (0) | 2023.02.22 |
day 3-2 python (Odd or Even Exercise)(홀수 또는 짝수) (0) | 2023.02.22 |
day 3-1 python (if/else 및 조건 연산자를 통한 흐름 제어) (0) | 2023.02.21 |