[Tutor] BMI calc
Peter Otten
__peter__ at web.de
Wed Mar 13 13:21:13 CET 2013
Shall, Sydney wrote:
> I am also a newbie, but I wish to learn, so I offer the following
> corrections.
> # Note. I do note know what units you are using.
> # I would use scientific, metric units. So you need to divide both
> weight and height by a suitable conversion factors.
> # Then you will not need the number 703.0, and the units in the second
> and third lines would be Kg/m. [Kilogram/Metre)
>
> def calc_BMI(weight,height):
> bmi = (weight/(height*height))*703.0
> print 'Your BMI is : ', BMI 'weight units/height units.' # You need
to put the correct text here.
> if bmi <=18.5:
> print 'underweight'
> if 18.5 <= bmi <= 24.9:
> print 'normal weight'
> if 25.0 <= bmi <= 29.9:
> print 'overweight'
> if bmi >= 30:
> print 'obese'
> return
A problem that I have not seen addressed yet:
What will this print for the guy who is 75.0 in high and weighs 200.0 lb?
His bmi is
>>> height = 75.0
>>> weight = 200.0
>>> weight/(height*height)*703.0
24.995555555555555
That's neither normal nor overweight, according to your categorisation.
More information about the Tutor
mailing list