Power Operator in PYTHON | Sololearn: Learn to code for FREE!
+ 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.

14th May 2020, 4:37 AM
‎‏‪‏‪Abhinav‬‏‬‏‎
‎‏‪‏‪Abhinav‬‏‬‏‎ - avatar
3 Answers
+ 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
14th May 2020, 9:12 AM
Batcher21
Batcher21 - avatar
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.
16th Jul 2021, 2:35 AM
Rookie
0
why we can't write that: print(2 ** 1.5) Gives us error
16th Feb 2023, 3:55 PM
Nikoloz Kuprashvili
Nikoloz Kuprashvili - avatar