0
Why 3/6 is 0 and 3/6.0 is 0.5 which is a float?
I understand that python automatically convert interger into float. why in the first case it's showing 0.
5 Antworten
+ 2
I think you are using python 2 version please use latest version of python. In version 3 , 3/6=0.5
and 0.5 is float.
+ 1
Maninder Singh yes I think I am . thanks for pointing out the issue.
0
If you divide an integer by another integer, the compiler assumes you are doing integer arithmetic, and therefore the result will be an integer too, in this case 0 because 6 doesn't fit in 3.
0
does it mean interger operation always return an integer?
0
Use python latest version 3.6