Q. What is the output of the Python code: print(list(range(1, 5)))?

A
[1, 2, 3, 4, 5]
B
[1, 2, 3, 4]
C
[0, 1, 2, 3, 4]
D
[2, 3, 4, 5]
Solution:

The range(1, 5) generates numbers from 1 to 4 (exclusive of 5), and list() converts it to [1, 2, 3, 4].

Entri PDF Icon

Get Question Bank

Strengthen Your Practice with our comprehensive question bank.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!