CBSE Class 11 Computer Science Question 113 of 161

Flow of Control — Question 22

Back to all questions
22
Question

Question 11h

Predict the output of the following code fragments:

for q in range(100, 50, -10):
   print (q)

Answer

Output
100
90
80
70
60
Explanation

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.

Answer