question # 3\nmultiple choice\nwhat is the output of the following program?\nnuma = 2\nnumb = 3\nwhile numa…

question # 3\nmultiple choice\nwhat is the output of the following program?\nnuma = 2\nnumb = 3\nwhile numa > 0:\n numa = numa - 1\n while numb > 0:\n numb = numb - 1\n print (numa, numb)
Answer
Explanation:
Step1: Analyze outer - loop initial condition
The outer while loop has the condition numA > 0. Initially, numA = 2.
Step2: First iteration of outer - loop
In the first iteration of the outer loop, numA becomes numA=numA - 1=2 - 1 = 1. Then the inner while loop starts. The inner while loop has the condition numB > 0 with numB = 3 initially. In the inner - loop, numB is decremented in each iteration. After three iterations of the inner loop, numB becomes 0. Then print(numA, numB) prints 1, 0.
Step3: Second iteration of outer - loop
In the second iteration of the outer loop, numA becomes numA=numA - 1=1 - 1 = 0. Now the outer - loop condition numA > 0 fails and the program terminates.
Answer:
The output is 1, 0