30.2k views
3 votes
Consider the following code:

for i in range (x, y):
print (i, end=" ")
What values for x and y will output the code below?

10 11 12 13 14 15 16 17 18 19

Group of answer choices

x = 19
y = 9

x = 10
y = 19

x = 10
y = 20

x = 19
y = 10

User Darkliquid
by
7.2k points

1 Answer

6 votes

Answer:

x = 10

y = 20

Step-by-step explanation:

The for loop is executed with the loop variable i taking on the values x, x+1, x+2, and so on, up to but not including y.

Since we want to output the numbers from 10 to 19 inclusive, we need to start the loop with x = 10 and end it with y = 20 (not inclusive).

The statement print(i, end=" ") is executed on each iteration of the loop, which prints the value of i followed by a space, without moving to a new line.

So the correct answer is x = 10 and y = 20.

User Illya Kysil
by
6.9k points