169k views
10 votes
What is the output for the following program?

numA = 10
while numA < 21:
numA = numA + 5
print(numA)

User Dopoto
by
3.9k points

1 Answer

12 votes

Answer:

Output:

15

20

25

Step-by-step explanation:

In first iteration value of num is 10. Condition is checked 10 is less than 21 so value of num is incremented by 5 and value 15 is printed than again condition is checked 15<21 so value of num is incremented again and 20 is printed. Again condition is checked 20<21. So 25 is printed. Then 4th time when condition is checked vakue of num is 25 and while loop condition becomes false because 25 is not less than 21 and program is terminated here.

User Azimi
by
4.0k points