CBSE Class 10 Computer Applications Question 8 of 26

Python Conditionals and Loops — Question 6

Back to all questions
6
Question

Question 6

What will the output of following code ?

for i in range(1, 0) :
    print i
  1. 0
  2. 1
  3. No output
  4. Error in code
Answer

No output

Reason — The function range(1, 0) will return return an empty list [] as no number falls in the arithmetic progression beginning with 1 and ending with 0. Thus, the for loop will not execute even once and hence, no output will be generated on the output screen.