728x90
문제
The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health.
The doctor measures the patient’s height (in metres) and weight (in kilograms), then calculates the BMI using the formula
BMI = weight/(height × height).
Write a program which prompts for the patient’s height and weight, calculates the BMI, and displays the corresponding message from the table below.
BMI Category | Message |
More than 25 | Overweight |
Between 18.5 and 25.0 (inclusive) | Normal weight |
Less than 18.5 | Underweight |
https://www.acmicpc.net/problem/6825
예제
# input
69
1.73
# output
Normal weight
# input
84.5
1.8
# output
Overweight
문제 풀이
W = float(input())
H = float(input())
BMI = W / H**2
if BMI > 25:
print('Overweight')
elif BMI >= 18.5:
print('Normal weight')
else:
print('Underweight')
파이썬을 독학하시는 분들에게 도움이 되길 바라며,
혹 더 좋은 방법이 있거나 오류가 있다면 편하게 말씀 부탁드립니다.
728x90