I was doing a function in python that returns me the results (x 'ex) of the bhaskara formula, just to train the logic a little bit. more, but it made me curious.
If I raise a negative number squared, the expected result is positive, right?
>>> -7 ** 2
-49
Not what happens if I do the above. However, if I assign -7
to a variable x
, for example, and try to raise x
to the square ...
>>> x = -7
>>> x ** 2
49
... the result comes out as expected. Why did not python do the operation correctly from the first mode?