Post

@PythonPr Answer: A
Solution: The main part is to figure out what the loop is over.
range(0, 5, 2) produces a sequence of numbers
- starting from 0
- up to, but excluding 5
- with increments of 2
So, the items in the range are: 0, 2, 4.
Note that 6 won't be in there, as it's >=5.
+
English

@PythonPr The answer is 6.
Following are the values of i: 0 2 4.
English

@PythonPr The answer is 3. With range(0,5,2), we will have 3 iterations (0,2,and 4). x begins as 0+1, so 1. The next iteration has x as 1+1 = 2. The last iteration has x as 2+1, so 3
English

@PythonPr The answer is 6.
The loop iterates over the values 0, 2, and 4 (range(0, 5, 2) excludes 5).
x = 0
x += 0 → 0
x += 2 → 2
x += 4 → 6
The loop then ends because the next value would be 6, which is outside the specified range.
English





















