CBSE Class 10 Computer Applications
Question 22 of 26
Python Conditionals and Loops — Question 13
Back to all questions 13
Question Question 9(b)
Predict the output of the following code fragments :
x = 10
y = 0
while x > y:
print x, y
x = x — 1
y = y + 1 Output
10 0
9 1
8 2
7 3
6 4
Explanation
| x | y | Output | Remarks |
|---|---|---|---|
| 10 | 0 | 10 0 | 1st Iteration |
| 9 | 1 | 10 0 9 1 | 2nd Iteration |
| 8 | 2 | 10 0 9 1 8 2 | 3rd Iteration |
| 7 | 3 | 10 0 9 1 8 2 7 3 | 4th Iteration |
| 6 | 4 | 10 0 9 1 8 2 7 3 6 4 | 5th Iteration |