CBSE Class 11 Computer Science Question 114 of 161

Flow of Control — Question 23

Back to all questions
23
Question

Question 11i

Predict the output of the following code fragments:

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

Answer

Output
-500
-400
-300
-200
-100
0
100
200
300
400
Explanation

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.

Answer