CBSE Class 11 Computer Science
Question 111 of 161
Flow of Control — Question 20
Back to all questions 20
Question Question 11f
Predict the output of the following code fragments:
for x in range(5):
print (x) Answer
Output
0
1
2
3
4
Explanation
range(5) will generate a sequence like this [0, 1, 2, 3, 4]. x will be assigned each of the values from this sequence one by one and that will get printed.