Q. Consider following three codes:
i = 0 while i < 10: i +=1 if i % 2 == 0: print(i) |
i = 0 while i > 10: i +=1 if i % 2 == 0: print(i) |
i = 0 while i < 1: i -= 1 if i % 2 == 0: print(i) |
What will be the outputs produced by these three codes and state the reason(s)?
Answer :-
Output1 | Output2 | Output3 |
---|---|---|
2 4 6 8 10 >>> |
It will not give output because condition in while loop is False. | It will run infinite times because condition in while loop is always True. |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )