Computer Science
Predict the output of the following code fragments:
for q in range(100, 50, -10):
print (q)
Python
Python Control Flow
9 Likes
Answer
100
90
80
70
60
Working
range(100, 50, -10) will generate a sequence like this [100, 90, 80, 70, 60]. q will be assigned each of the values from this sequence one by one and that will get printed.
Answered By
3 Likes
Related Questions
Predict the output of the following code fragments:
for x in range(5): print (x)
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 z in range(-500, 500, 100): print (z)
Predict the output of the following code fragments:
for y in range(500, 100, 100): print (" * ", y)