how can i calculate float value?
eg it is 32/10 3.2 in calculator
in python 32/10 is 3.0
help me out

Recommended Answers

All 2 Replies

from __future__ import division
print 32/10
"""
My output:
3.2
"""

Basically, the from __future__ import division, will convert the / operator into the floor division operator, which will do the exact division.
Note that if you do such thing, the / operator which was before, meaning 32/10=[3], the real part of the number, will be changed to the floor division operator, and its effect will last throughout all script.
Another way is to use the double div operator, //

32//10

but I'm not that sure it will work, heh :D, gotta try:P

Later edit: Apparently the // ain't working for me...
You can get further help at this websites:
http://docs.python.org/release/2.2.3/whatsnew/node7.html
or
http://docs.python.org/reference/expressions.html

thankyou ,32//10 is not working

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.