Computer Science
Predict the output of the following code fragments:
for x in [1,2,3]:
for y in [4, 5, 6]:
print (x, y)
Python
Python Control Flow
11 Likes
Answer
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
Working
For each iteration of outer loop, the inner loop will execute three times generating this output.
Answered By
6 Likes
Related Questions
Predict the output of the following code fragments:
for y in range(500, 100, 100): print (" * ", y)
Predict the output of the following code fragments:
x = 10 y = 5 for i in range(x-y * 2): print (" % ", i)
Predict the output of the following code fragments:
for x in range(3): for y in range(4): print (x, y, x + y)
Predict the output of the following code fragments:
c = 0 for x in range(10): for y in range(5): c += 1 print (c)