Python · Question 19 · Easy

What will be the output of the following Python code?

print(list(range(2, 12, 3)))
  1. [2, 5, 8, 11]
  2. [3, 6, 9]
  3. [2, 5, 8, 11, 14]
  4. [2, 5, 8]
Answer and explanation

Answer: A. [2, 5, 8, 11]

Explanation: range(2, 12, 3) starts at 2 and adds 3 each time while staying below 12: 2, 5, 8, 11.

Previous: What will be the output of the following Python code? · Next: What will be the output of the following Python code?

Practise python

Try a fresh set of python questions with an explanation after every answer, free and without signing up: Python practice. Or sit a full placement mock test.

More python questions

More technical & programming practice

Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge