Post

@PythonPr Indentation matters in Python.
print(x) is inside the loop, so it runs every iteration.
Output will be:
0
1
3
None of the given options are correct.
English

@PythonPr So, I wanted to commend @KamalGurjar8 in his reply for spotting the wrong indentation, but he already blocked me because he feel threatened when I criticized his wrong answer in an earlier post 🤣.
But now, he appears correct with his answer. Take note of your indentation
English

@PythonPr For i in range(3) is 0,1,2
x = x + i is (0+0) + (0+1) + (0+2)
x = 3
Answer is A
English

@PythonPr The answer is A) 3
In range (3) to repeat the answer in the number in range, x = x+1 will be repeated 3 times,
0 + 1 =1
1 + 1 = 2
2 + 1 = 3
the answer: x=3

English

@PythonPr x = 0
for i in range(3):
x = x + i # i takes values 0, 1, 2
print(x) # 0 + 0 + 1 + 2 = 3
Answer would be 3:
English

@PythonPr Indentation error on this code .
If no error then output will be 3
English































