Embercode
✕
OperatorsQuick quiz

Shifts and integer sizes in Python

7 questions. Covers Augmented assignment and fixed-size numbers in Python.

Questions 1 to 5 of 7

  1. 1. What does this program print? ``python a = -16 print(a >> 2) print((a & 0xFFFFFFFF) >> 2) ``
  2. 2. What does this program print? ``python b = 127 b += 2 print(b) ``
  3. 3. This loop should count how many shifts it takes for x to reach 0. What goes wrong? ``python x = -16 count = 0 while x != 0: x >>= 1 count += 1 ``
  4. 4. What does this program print? ``python hits = 0 hits = hits + 1 print(hits) ``
  5. 5. True or false: in Python, -7 >> 1 and -7 // 2 give the same answer.

5 question(s) left on this page.