Arithmetic issue


#1

bool_2
-(-(-(-2))) == -2 and 4>= 16**0.5

#What do I do with -2 each time I see a ( should I be multiplying here?
Is it -2*-2*-2 ?

bool_3
19% 4 != 300/10/10 and FALSE

#So remainder 19 what do I do with remainder 19 and 4? Add them?

bool_4
-(12)<20 and 10% <= 20 -10*2

#Once I calculate Exponentiation what do I do with … -(value) ?
Whatever it is probable it will be negative number making the left portion TRUE -(value) is less than 0

Yes I should know this but don’t.


#2

All those negatives are each equivalent to -1, so,

-1 * -1 * -1 * -1 * 2

but we know that an odd number of multiplications will be negative, and an even number will be positive, so,

1 * 1 * 2

or positive 2.

We can see that 2 is not equal to -2 so that is False. Seeing that the expression is an AND, which short-circuits on False, we do not need to complete the evaluation. It won’t matter. False and … ends right there. False.

19 % 4 is the remainder of 19 / 4, which is 3 (19 - 16), and 300 / 100 is 3, so that is True. But again, the False in the second operand means we didn’t need the first one. The answer is automatically False.

We’ll need an expression that makes sense for bool_4. There seems to be a typo or some missing bits in your example.


#3

bool_4
-(12)<20 and 10%<= 20 -10*2

Question: Once I calculate the exponentiation = 1
do I then -1*1 ?

Thank you for your previous comments it REALLY HELPED!


#4

I swear I am trying to post the symbols for exponentiation but must be doing it wrong.


#5

Try posting a link to the exercise and we can grab the expression from there.


#6

-(1 ** 2) < 2 ** 0 and 10 % 10 <= 20 - 10 * 2


#7
-(1 ** 2) < 2 ** 0 and 10 % 10 <= 20 - 10 * 2
-1 * -1 => 1
2 ** 0  => 1

so, False. We can stop there.


#8

Thank you so much again!!! Now I can finish this chapter.

Very happy with codeacademy so far.

Tried “PYTHON Programming” with John Zelle little deep a little fast. But between this website and his book I am finding some of my answers on my own.

Thank you again


#9

Oops! Just spotted an obvious error in my evaluation.

- (1 ** 2)  =>  -1

so, True, which means evaluating the second operand.

0 <= 0

also True, so the expression is True.

Sorry about that.


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.