KnowledgeBoat Logo

Class - 12 CBSE Computer Science Important Output Questions 2025

Predict the output of the following code fragments:

for z in range(-500, 500, 100):
    print (z)

Python

Python Control Flow

17 Likes

Answer

-500
-400
-300
-200
-100
0
100
200
300
400

Working

range(-500, 500, 100) generates a sequence of numbers from -500 to 400 with each subsequent number incrementing by 100. Each number of this sequence is assigned to z one by one and then z gets printed inside the for loop.

Answered By

7 Likes