PCAP Object-Oriented Programming Practice Question
A class `Circle` has a class attribute `pi = 3.14`. An instance `c = Circle()` sets `c.pi = 3.14159`. What is the value of `Circle.pi` after this assignment?
⚠ Common exam trap
The trap here is thinking that assigning to an instance attribute with the same name as a class attribute changes the class attribute.
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
✓
3.14
In Python, attribute assignment on an instance always creates or modifies an instance attribute, even if a class attribute with the same name exists. The class attribute is only modified when assigned via the class itself, such as `Circle.pi = value`. Here, `c.pi = 3.14159` adds an instance attribute to `c`, leaving `Circle.pi` at 3.14.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
3.14
Why this is correct
Class attributes are shared across all instances unless overridden by an instance attribute. When `c.pi = 3.14159` is executed, Python creates an instance attribute `pi` on `c`, shadowing the class attribute for that instance. The class attribute `Circle.pi` is not modified and retains its original value of 3.14.
- ✗
An AttributeError is raised because class attributes cannot be shadowed.
Why it's wrong here
Class attributes can be shadowed by instance attributes. Python allows an instance to have an attribute with the same name as a class attribute. The assignment `c.pi = 3.14159` is valid and simply creates an instance attribute. No `AttributeError` occurs. This option misstates Python's attribute lookup rules.
- ✗
The value is undefined because class attributes are immutable.
Why it's wrong here
Class attributes are not immutable; they can be reassigned using `Circle.pi = value`. However, in this scenario, the assignment is on the instance `c`, not the class. The class attribute remains 3.14. The concept of immutability does not apply here, and the value is well-defined.
- ✗
3.14159
Why it's wrong here
Assigning `c.pi = 3.14159` creates or updates an instance attribute named `pi` on the object `c`. It does not modify the class attribute `Circle.pi`. Therefore, `Circle.pi` remains unchanged at 3.14. This option incorrectly assumes that instance assignment affects the class attribute.
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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
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.