CBSE Class 11 Computer Science Question 117 of 161

Flow of Control — Question 26

Back to all questions
26
Question

Question 11l

Predict the output of the following code fragments:

for x in [1,2,3]:
    for y in [4, 5, 6]:
        print (x, y)

Answer

Output
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
Explanation

For each iteration of outer loop, the inner loop will execute three times generating this output.

Answer