Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question # 2 multiple choice what is the output for the following progr…

Question

question # 2
multiple choice
what is the output for the following program?
for numx in 3,5:
for numy in 1,2:
print (numx, numy)
3 1
3 2
5 1
5 2

Explanation:

Step1: Outer - loop iteration 1

The outer loop iterates over [3, 5]. First, numX = 3. Then the inner - loop iterates over [1, 2]. When numY = 1, print(numX, numY) prints 3 1. When numY = 2, print(numX, numY) prints 3 2.

Step2: Outer - loop iteration 2

Next, in the outer - loop, numX = 5. The inner - loop again iterates over [1, 2]. When numY = 1, print(numX, numY) prints 5 1. When numY = 2, print(numX, numY) prints 5 2.

Answer:

3 1
3 2
5 1
5 2