hey

with this code that ive written, im not sure why its not outputting a value for the BMI..

can anyone help??

thanks

def application(environ, start_response):


    headers = [('content-type', 'text/html')]
    start_response('200 OK', headers)


    formdata = cgi.FieldStorage(environ=environ, fp=environ['wsgi.input'])


    if formdata.has_key('Mass') and formdata.has_key('Height'):
        Mass = float(formdata.getvalue('Mass'))
        Height = float(formdata.getvalue('Height'))
        BMI = formdata.getvalue('Mass/(Height*Height)')
        forminfo = "<p>Mass= %s, Height=%s, BMI=%s</p>" % (Mass, Height, BMI)
    else:
        forminfo = "no data input" 



    page = ["<html>", BMI_form, forminfo, "</html>"]




    return page

Recommended Answers

All 4 Replies

i found the problem.

but when i changed the BMI = formdata.getvalue('MAss/(Height*height)')

to BMI = (mass/height*height)

the value is wierd..
if i put 50kg and 150cm
0.00222222222222

which should be 22

or 60kg and 170cm
its 0.00207612456747

20.8

ive tried using float infront still doesnt change.. umm ive multipled it by 100, 1000...

no difference its still wierd.

thanks

wait dont worry....

about that..

but if i wanted to get it to a whole number like 22 or 20.8

how would i do that?

what did you do when bmi was not outputting?
I am having the same problem at the moment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.