CBSE Class 11 Computer Science Question 59 of 161

Flow of Control — Question 41

Back to all questions
41
Question

Question 41

Consider the following loop:

j = 10
while j >= 5:
    print("X")
    j=j-1

Which of the following for loops will generate the same output as the loop shown previously?

  1. for j in range(-1, -5, -1):
        print("X")
  2. for j in range(0, 5):
        print("X")
  3. for j in range(10, -1, -2):
        print("X") ✓
  4. for j in range(10, 5):
        print("X")
  5. for j in range(10, 5, -1):
        print("X")
Answer