+ 1
Why am i getting 0 as output in Python
Print(24/26)
5 Réponses
+ 4
Okay, so if you tried doing something like this in Python 2.x:
print 24/26
it would perform floor division, which gives the integer not exceeding the actual result of the division. In Py 2.x, you'd need to do 24.0/26 or 24/26.0 to get accurate result, like Mert suggested.
+ 7
In Python2, a / b returns an integer if both a and b are integers. You should convert one of them to float to have float result
2 / 4 -> 0
2.0 / 4 -> 0.5
+ 3
Hi Sotomi Oluwadmilola
That's strange! Are you using Python 3.x? If so, you shouldn't get zero as output. Could you please save your code in the Code Playground and share a link with us? Thanks!
+ 2
We called the float in Python.
0
My Python editor is an old version.. Code worked well in the code playground