Informatics Practices

Find the output of the following Python program:

for x in range(1, 20, 3):
   print(x, end =',')
  1. 1,20,3,
  2. 1,4,7,10,13,16,19,
  3. 13,6,9,12,15,18,
  4. 20,40,60,80,100,

Python Control Flow

2 Likes

Answer

1,4,7,10,13,16,19,

Reason — The above code uses a for loop to iterate over a sequence of numbers generated by range(1, 20, 3). This range starts at 1, ends before 20, and increments by 3 in each step. During each iteration, the current value of x is printed followed by a comma due to the end=',' parameter in the print function. Therefore, the output is 1,4,7,10,13,16,19, showing the sequence of numbers separated by commas.

Answered By

1 Like


Related Questions