Bird
0
0

What will be the output of this pseudo-code?

medium📝 Analysis Q5 of 15
LLD - Advanced LLD Concepts
What will be the output of this pseudo-code?
immutable_list = [1, 2, 3]
immutable_list.append(4)
print(immutable_list)
AError: Cannot modify immutable list
B[1, 2, 3, 4]
C[]
D[1, 2, 3]
Step-by-Step Solution
Solution:
  1. Step 1: Understand immutability of list

    An immutable list cannot be changed after creation, so append is disallowed.
  2. Step 2: Predict behavior of append

    Calling append on immutable list causes an error.
  3. Final Answer:

    Error: Cannot modify immutable list -> Option A
  4. Quick Check:

    Appending immutable list = Error [OK]
Quick Trick: Immutable collections disallow modification methods [OK]
Common Mistakes:
  • Assuming append works on immutable lists
  • Expecting list to remain unchanged silently
  • Ignoring immutability enforcement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes