0
For 3/4 operation it's showing 0 not 0.75, why.!?
I've installed python version 2.7, and float thing is not properly shown ie. showing integer value. as 10/2 should show 5.0 instead showing only 5.
5 ответов
+ 4
In Python < 3.x, division ( / ) is integer if both operands are integer. You must explicit at least one of the argument as float to have a float returned... try:
3.0/4 # will return 0.75
Since Python 3, the division ( / ) return a float in all case, when you need to use the double slash operator ( // ) for integer division...
To reproduce this behaviour in Python 2.7, you can add:
from __future__ import division
... on begining of your script ;)
[ EDIT ]
Or before you attempt to calculate a division, in a command line interpretor, once per session...
0
let me see your code!
0
It's a simple operation...
3/4
which should give me0.75 bt gives output of 0
0
Thank you just now figured out. And answer was posted.
0
yes and this issue is with python< 3.x...thanks for this too.