CBSE Class 10 Computer Applications
Question 7 of 26
Python Conditionals and Loops — Question 5
Back to all questions 5
Question Question 5
What will be the output of following code ?
for i in range(1) :
print i- 0
- 1
- No output
- Error in code
0
Reason — The range(n) function generates a list as [0, 1, 2..., n - 1]. Thus, the range(1) function will generate a list as [0]. Thus the for loop will execute only one time and print 0 on the output terminal.