PCAP Strings Practice Question
Which of the following best describes the immutability of strings in Python?
⚠ Common exam trap
Python Institute often tests the confusion between object mutability and variable reassignment, leading candidates to incorrectly believe that strings can be modified in place or that they cannot be reassigned at all.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Strings cannot be changed after creation, but variables can be reassigned.
Strings in Python are immutable objects, meaning once a string is created, its contents cannot be changed. However, the variable referencing the string can be reassigned to point to a new string object. This distinction between mutability of the object and reassignment of the variable is fundamental to Python's data model.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Strings can be modified in place using indexing.
Why it's wrong here
Attempting to set a character by index, such as s[0] = 'x', raises a TypeError because the str type does not support item assignment. Indexing on strings is strictly a read operation that retrieves a character without exposing any mechanism to modify the underlying sequence. The inability to use subscript assignment reflects the immutability of string storage, so strings can never be altered in place.
- ✗
Strings are mutable but require special methods.
Why it's wrong here
Mutability is a fundamental trait of a type, not a functionality that can be toggled through particular methods; strings are immutable by design. Any method that appears to alter a string—like upper(), replace(), or concatenation—actually creates and returns a brand-new string object, leaving the original untouched. There are no special methods or workarounds that can mutate a string in place because the runtime does not allow the internal character buffer to change.
- ✗
Strings cannot be reassigned.
Why it's wrong here
Reassigning a variable, such as s = s + 'a', changes which object the name refers to, but it does not modify the original string object in any way. Immutability governs the object's internal state—its characters and length cannot be changed—not the variable's ability to point elsewhere. Confusing variable rebinding with object mutation is a common mistake; the variable is just a reference, and rebinding it is always permitted regardless of the object's mutability.
- ✓
Strings cannot be changed after creation, but variables can be reassigned.
Why this is correct
This is the correct distinction: the str object itself is immutable, so once a string is created its contents cannot be altered, added to, or removed. However, a variable that references a string can be assigned a new value, such as s = 'new', which makes the variable point to a different string object. This separation between object identity and variable binding is fundamental to Python's data model and explains why strings can appear to 'change' when they actually are being replaced.
Go deeper
Related to this question
About these practice questions
This PCAP question is part of Courseiva's 421-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.