Computer Applications
What will the output of following code ?
for i in range(1, 0) :
print i
- 0
- 1
- No output
- 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
2 Likes
Related Questions
Which of the following is used to define a block of code (e.g., body of if or body of a loop) in Python ?
- { }
- ( )
- indentation
- Quotation
What will be the output of following code ?
for i in range(1) : print i
- 0
- 1
- No output
- Error in code
What is the output of following code ?
if None : print "Up" else: print "Down"
- Up
- Down
- No output
- Up Down
What is the output of following code ?
while 3 >= 3 : print 3
- 3 is printed once
- 3 is printed three times
- 3 is printed infinitely until program is closed
- Error in code