173k views
4 votes
Read the following code:

n = 0
while(n <= 5):
print(n)
n = n + 1

What output would be produced for the given values of n?
0 1 2 3 4
0 1 2 3 4 5
1 2 3 4
1 2 3 4 5

User Yome
by
8.8k points

1 Answer

4 votes

Answer:

0

1

2

3

4

5

Step-by-step explanation:

The loop first prints when n is still 0, so 0 is in the list.

The loop still executes when n = 5, so 5 must also be in the list.

User Marek Dzikiewicz
by
8.0k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.