0

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

Edited by pyTony: format fixing

3
Contributors
4
Replies
13
Views
5 Years
Discussion Span
Last Post by nadeem.lalani.3
0

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

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.