Post

Correct answer: A) 0 1 2
Many people pick C because they mentally read while x <= 3 — but it's strict < 3.
Quick breakdown:
x = 0 → print 0, x becomes 1
x = 1 → print 1, x becomes 2
x = 2 → print 2, x becomes 3
x = 3 → 3 < 3 is False → loop stops
+ end=" " keeps everything on one line with spaces.
What was your first guess? 👇 Did the < vs <= trick get you? 😅
#Python #Coding #Programming
English

@PythonPr A) 0,1,2 is right answer.
Simple use of while loop and print the value. 0<3 then print 0 then update the value of x = 1 and 1<3 true print 1 then update the value x is 2 and 2<3 condtion true print 2 then update the value of x 3<3 condition false and loop stop.
English

@PythonPr Answer —A
Simply because x will always be less than 3 in loop and not equal to 3.
English

@PythonPr A
- x = 0, Condition: x < 3 → True, Prints 0, Increments x → x = 1
- Next loop: x = 1, still < 3, Prints 1, Increments x → x = 2
- Next loop: x = 2, still < 3, Prints 2, Increments x → x = 3
- Next loop: x = 3, condition x < 3 → False → loop ends.
Final Output
`
0 1 2
`
English

Ans--->A 012
The code initializes the variable x to 0. The while loop continues as long as the condition x<3 is true.
Iteration 1: x is 0. The condition 0<3 is true. The value 0 is printed. x becomes 1. Iteration 2: x is 1. The condition 1<3 is true. The value 1 is printed. x becomes 2. Iteration 3: x is 2. The condition 2<3 is true. The value 2 is printed.xbecomes 3. Iteration 4: x is 3. The condition 3<3 is false. The loop terminates.
The end="" argument in the print function ensures that the numbers are printed on the same line without a newline character after each number. The final output is 012.
English

























