XuMuK XuMuK - 2 months ago 22
Python Question

Python mathematical operators sequence

a=0
b=5


And when we try to get result of this:

print str((23-11)/a*b)


We get the divide by zero error.


Traceback (most recent call last): File "", line 1, in

print str((23-11)/a*b) ZeroDivisionError: integer division or modulo by zero
But if we change positions:


print str((23-11)/b*a)


The result is zero:


0


Should we get always divide y zero error (because (b*a) is zero)?

Answer

((23-11)/a*b) becomes

enter image description here

((23-11)/b*a) becomes

enter image description here

Comments