Computer Science
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?
- for j in range(-1, -5, -1): <br/> print("X")
- for j in range(0, 5): <br/> print("X")
- for j in range(10, -1, -2): <br/> print("X")
- for j in range(10, 5): <br/> print("X")
- for j in range(10, 5, -1): <br/> print("X")
Python Control Flow
2 Likes
Answer
for j in range(10, -1, -2): <br/> print("X")
Answered By
3 Likes
Related Questions
How many times does the following code execute ?
x = 1 while (x <= 5): x + 1 print (x)What is the output produced when this code executes?
i = 1 while (i <= 7): i*= 2 print (i)What is the output produced when this code executes?
a = 0 for i in range(4,8): if i % 2 == 0: a = a + i print (a)Which of the following code segments contain an example of a nested loop?