QUESTION IMAGE
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
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.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
3 1
3 2
5 1
5 2