Computer Applications

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

Python Control Flow

1 Like

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.

Answered By

1 Like


Related Questions