Canadian Computing Competition: 2008 Stage 1, Junior #1
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:
Write a program which takes the patient's weight and height as input, calculates the BMI, and displays the corresponding message from the table below.
BMI Category | Message |
---|---|
More than |
Overweight |
Between |
Normal weight |
Less than |
Underweight |
Sample Input 1
69
1.73
Output for Sample Input 1
Normal weight
Explanation of Output for Sample Input 1
The BMI is which is approximately
. According to the table, this is a "Normal weight".
Sample Input 2
84.5
1.8
Output for Sample Input 2
Overweight
Explanation of Output for Sample Input 2
The BMI is , which is approximately
. According to the table, this is "Overweight".
Comments
Damn, I was so confused on why I kept getting the last case wrong and then I realized I put a capital in Normal weight.
This comment is hidden due to too much negative feedback. Click here to view it.
for the "Normal weight" I had it check if it was not in between 18.5 and 25 instead of in-between
How do you multiply decimals in python3? Mine always says,
Traceback (most recent call last): File "program.py", line 2, in <module> h = int(input()) ValueError: invalid literal for int() with base 10: '1.73'
Do you have to do some weird maths formula to work your way around this?
Instead of reading input with
int(input())
read it as a floatfloat(input())
.Thank you! I now know how to use decimals in python maths!
I got so confused when I saw the output and when I realized it was weight first and not height, I got kinda salty.😂😂😂😂😂😂😂😂
Mine always says IR for the execution results lol
me too it always say INput mismatch
how do you make it so that it doesn't tell you INput misMatch all the time, I try to insert a decimal in the console and it can't show up.
"Write a program which prompts for the patient's height and weight" should be changed. No prompting should be done, and the input order is weight first, then height.
Fixed, thanks!
This comment is hidden due to too much negative feedback. Click here to view it.
Mans writing decimals like ip addresses