In python 2**3 equates to pow(2,3)
but somehow -1**0 is not equal to pow(-1,0)
The first gives an unexpected output of -1 ?
Can somebody explain why ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
**takes precedence over the-, so your code is being evaluated like this:To get the same answer, add parentheses:
The documentation explains the
**operator a little more right here: http://docs.python.org/2/reference/expressions.html#the-power-operator