QUESTION IMAGE
Question
question 18
what is the output of the following code?
i = 1
while i <= 2:
j = 1
while j <= 3:
print(*, end = )
j += 1
print()
i += 1
Step1: Analyze the outer loop
The outer loop runs when \(i\leq2\). Initially \(i = 1\).
Step2: Analyze the inner loop for \(i = 1\)
When \(i = 1\), the inner loop \(j\) runs from \(1\) to \(3\). So, it prints ** (three s) and then print() makes a new line.
Step3: Update \(i\) and analyze for \(i = 2\)
\(i\) becomes \(2\). The inner loop again runs \(j\) from \(1\) to \(3\), prints *** and a new line. Then \(i\) becomes \(3\) and the outer loop stops.
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
***
***