What is the value of `s` after: `s = 0` / `for i in range(3, 9, 2): s += i`?

Answer and explanation

Correct answer: C. 15

  1. Step 1: The loop uses i = 3, 5, 7.
  2. Step 2: Their sum is 15.
Answer
15.
Why not the others: 24, 33 and 17 do not fit.

Practise more Python programming and algorithms.

Free questions with an explanation for every one, and full timed Saudi Secondary School Certificate mock tests.