Logic and bit operations

Module 3 · Logic and bit operations · Lesson 6 of 6

Quiz

Five questions spanning logical operators, bitwise operators and shifts. Work each out before you check.

1

What does this evaluate to?

True and False
2

What is the result of this bitwise AND?

5 & 3
3

When should you use the word 'and' rather than '&'?

4

What is this?

1 << 3
5

What does x >> 1 do to x?

You've now seen logic at both levels — whole True/False values, and the individual bits underneath. That rounds out Module 3's tour of how programs reason and repeat.