Embercode
✕
OperatorsQuick quiz

Evaluation order and precedence in Python

8 questions. Covers Precedence trees in Python.

Questions 1 to 5 of 8

  1. 1. What does this code print? ``python k = 2 m = k + (k := k + 1) * 3 print(m, k) ``
  2. 2. This loop is meant to count to 3, but it prints 0. What is the bug? ``python count = 0 for n in range(3): count + 1 print(count) ``
  3. 3. What does this line print? ``python print(10 - 4 - 3) ``
  4. 4. With i = 4, the line i = (i := i + 1) - 1 leaves i equal to 5. True or false?
  5. 5. What does this code print? ``python w = [1, 2, 3] p = 1 w[p] = (p := p + 1) * 10 print(w, 'p=' + str(p)) ``

5 question(s) left on this page.