Software Engineer (SDE)pythonbeginner3 interactive MCQs in app
Classes, Objects & __init__
instance attributes (self.x) vs class attributes__init__ initialization and invariantsmethod self binding
Core Concept
Classes bundle data attributes and cohesive behavior via `__init__(self, ...)` and instance methods receiving `self`. Attributes defined inside `self.attr = ...` belong to each object instance, whereas attributes directly in the class body are shared across ALL instances!
Worked Example
putting `scores = []` at class level shares one list across every `Student`; assigning `self.scores = []` inside `__init__` isolates each instance.
Common Pitfall
confusing class vs instance attributes (especially mutable lists/dicts on the class body) or mutating state without validation.
Recommended Readings & Practice
Practice Classes, Objects & __init__ with 3 graded MCQs & written feedback.
Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.