216k views
20 votes
What will the following program print when run?

for j in range(2):
for i in range(6, 4, -1):
print (i)

User Kihats
by
7.8k points

1 Answer

7 votes

Answer:

6, 5, 6, 5

Step-by-step explanation:

The first for means it will run twice. The second one will start at 6 and -1 until it gets to 4 where it will stop before doing anything. We say the first number IS inclusive and the second number ISN'T. The second one produces 6, 5 once but happens twice because of the first for.

User Mark Lauter
by
9.2k points

No related questions found

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