Question-95: When you run below program, what would happen
n=5
while(n):
print("Current Value = " , n )
n=n-1
print("Program Ends, Current Value=" , n)
- There would be infinite iterations.
- Get all Questions and Answer from here
- You need to have paid subscription to access all questions
- Thanks for considering Python Certification Material
Answer: B,E
Exp: As we are reducing value on n by 1 in each iteration. Hence, after 5th iteration n=0. And whenever you use 0 as if condition or while loop, it is considered as False. Hence, no further iterations.
You can access to full explanation to question and answer from this page.