Q. What does the Python code: x = (1, 2, 3); x[1] = 5 print(x) output?

A
[1, 5, 3]
B
(1, 5, 3)
C
(1, 2, 3)
D
Error
Solution:

Tuples in Python are immutable, so assigning a new value to an index (x[1] = 5) raises a TypeError.

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!