KnowledgeBoat Logo

Computer Science

Predict the output of the following code fragments:

for x in range(5):
   print (x)      

Python

Python Control Flow

13 Likes

Answer

0
1
2
3
4

Working

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.

Answered By

4 Likes


Related Questions