I wanted to start by asking about this. This was given to me as part of the exercise on codeacademy.com and confused me for most of the hour.
Take a look at the following block of code:
bool_one = 40 / 20 * 4 >= -4**2
Now I rated it as "8> = 16", which is False.
However, the codeacademy.com terminal says True. When I started writing lines of debugging code, I found that the problem is how "-4 ** 2" is evaluated. When I run it on the terminal in CodeAcademy, as well as on my local Linux system, "-4 ** 2" in Python goes to "-16" ... which contradicts everything that I learned in all my math classes and also every calculator on which I ran it. I run it as "-4 * -4" or "-4 ^ 2" or even using the key "x ^ y", "-4 [x ^ y] 2", it still comes out as "16". So what does python look like with "-16" for "-4 ** 2"?
Can someone clarify this for me?
TIA.
source share