PCEP 30 02 PCEP Certified Entry Level Python Programmer · Free Practice Question Easy
Question 3
What is the expected output of the following code?
tup = (1, 2, 3)
tup[1] = 4
print(tup)
-
A
(1, 4, 3)
-
B
(1, 2, 3)
-
C
Error
-
D
None of the above
Reveal correct answer
Correct answer: C
C.
Tuples are immutable in Python. Attempting to modify an element results in a TypeError.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
