These are getting complex, is there an easy way to solve them?

As it turns out, this is not a trivial concern. Some forethought would be an indicated requisite. Now that you have opened the door, be sure to walk around the lab and take in the experiments.


// Bitwise double not operator in JS

for a beginning…

Extra Reading

Extra Study

>>> a = 0
>>> not (not a and not 0)
>>> a = 1
>>> not (not a and not 0)
1 Like

casting to my ear suggests reinterpretation of the underlying bits

you could for example read 01001000 as 72 if you cast it to int or you could cast it to char and get 'H', or maybe you’d cast a 64 bit int to a 32 bit int and lose the 32 higher ones in the process because they don’t fit

You might convert 72 to a string and get "72" and you might convert 'H' to "H"

In python we don’t care too much about bits so we do conversions.


Why did you evaluate the AND first of the following statement?

True or False and False

that does not evaluate at all. or short-circuits

in any case, it’s no different from grade school math. follow operator precedence, left to right for ties.

1 Like

Long story short, there is a precence, right?

! > && > ||

1 Like

“because and requires both conditions to be true.”

That not False.

Why not false? True or False => True

OR is evaluated from left to right.

A or B

Above, A and B are expressions. They may be comparisons, operations or values. Expressions have what is known as, truth value. We call this truthiness.

The order of evaluation is left to right, as we’ve said. The first evaluation is expression A. If it is truthy then the operation stops and the value of A is yielded. If it is falsy then expression B is evaluated (if necessary) and that value is yielded.

True or False
    True is yielded

False or True
             True is yielded

False or False
              False is yielded

Thank you so much for this explanation - the tutorial should break it down like this!

We learn by examples, it’s not just copying but also analyzing what you’re writing

Thanks much for the details!!! I was confused at the beginning too. Then, reading your notes really enlightened me! I have then gone back and done it! It is really helpful when doing it! Thanks much for the hints!!

The login analogy makes this make sense. Thanks!

Thanks that really helped it make sense!