+ 2
Power Operator in PYTHON
>>> -2 ** 4 -16 #Here, -(2**4) = -(16) = -16 >>> 4**-2 0.0625 #Here, execution ?? mathematics : 1/4^2 = 1/16 = 0.0625. Please Explain.
3 Réponses
+ 1
Tht's because it's a negative power, so 4**-2=1/4**2, but if you power a negative number, that doesn't happen. The powers aren't conmutative bro
0
Python documentation says:
The power operator ** binds less tightly than an arithmetic or bitwise unary operator on its right, that is, 2**-1 is 0.5.
0
why we can't write that:
print(2 ** 1.5)
Gives us error