What will be the output of the following Python program?

for i in range(3):
    print(i, end=" ")
                        

Options

  • A. 1 2 3
  • B. 0 1 2
  • C. 0 1 2 3
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. 0 1 2

Detailed Explanation

The range(3) function generates 0, 1 and 2. The stop value 3 is excluded.