0
1/3 gives zero on my python
4 ответов
+ 4
Print (float(1/3))
gives you your answer of 0.333 recurring
You need to make the answer a float. Integers divided by integers always result in integers
+ 2
its integer type, so it will give you zero if the result was decimal
+ 1
no, float(1/3) will not give 0.333 it will give output 0.0...
float (1)/3 will give 0.333, in the above case float statement is converting 1/3 to float while in second case it is converting 1 to float then division occurs..
1/3 is int type that's why it will give output as 0..
+ 1
You are using Python 2, unfortunately for you...