Computer Science
Predict the output of the following code fragments:
for z in range(-500, 500, 100):
print (z)
Python
Python Control Flow
29 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
12 Likes
Related Questions
Predict the output of the following code fragments:
for p in range(1,10): print (p)Predict the output of the following code fragments:
for q in range(100, 50, -10): print (q)Predict the output of the following code fragments:
for y in range(500, 100, 100): print (" * ", y)Predict the output of the following code fragments:
x = 10 y = 5 for i in range(x-y * 2): print (" % ", i)