35 cards
Class
A blueprint for creating objects, containing attributes and methods.
Object
An instance of a class with specific values for attributes.
Inheritance
A mechanism where a new class can inherit attributes and methods from an existing class.
Encapsulation
The bundling of data and methods that operate on the data within a single unit or class.
Polymorphism
The ability to present the same interface for different data types.
What is a 'magic method' in Python?
Special methods with double underscores at the beginning and end, like `__init__` and `__str__`, that enable operator overloading and other functionality.
__init__
The constructor method in a class, initializing object attributes.
Method Overloading
A concept where two or more methods in the same class have the same name but different parameters. (Limited support in Python)
Method Overriding
Defining a method in a subclass with the same name and parameters as in the parent class, replacing the parent's method.
What is a 'decorator' in Python?
A function that modifies the behavior of another function or method, usually defined with the `@decorator_name` syntax.
@staticmethod
A decorator that defines a method in a class that does not operate on an instance or class itself.
@classmethod
A decorator that defines a method that operates on the class itself, not on an instance.
Self
A reference to the current instance of the class, used to access variables and methods.
What is Multiple Inheritance?
A feature where a class can inherit attributes and methods from more than one parent class.
MRO (Method Resolution Order)
The order in which base classes are searched when executing a method, typically using the C3 linearization algorithm.
Duck Typing
A concept where the type or class of an object is determined by its behavior (methods and properties) rather than its explicit declaration.
What is a 'metaclass' in Python?
A class of a class that defines how a class behaves. A class is an instance of a metaclass.
Inheritance Hierarchy
The structure of classes connected through inheritance, forming a tree.
What is the purpose of the `super()` function?
To call methods from a parent class, often used to extend the behavior of inherited methods.
Abstract Base Class (ABC)
A class that cannot be instantiated and often includes abstract methods that must be implemented by subclasses.
What is a 'singleton' pattern?
A design pattern that restricts the instantiation of a class to a single object.
What is 'composition' in object-oriented programming?
A design principle where a class is composed of one or more objects from other classes, representing a 'has-a' relationship.
Interface
A class that defines methods that must be created within any child classes built from the interface.
What is the use of `__repr__` method?
To provide an official string representation of an object, often used for debugging.
Dynamic Typing
A feature where the type of a variable is interpreted at runtime, allowing flexibility in Python.
What is the 'observer' pattern?
A design pattern where an object (subject) notifies a list of observer objects about state changes, often used in event handling systems.
Namespace
A container that provides a scope to identifiers such as variables, functions, classes, etc.
What is 'operator overloading'?
A feature that allows the same operator to have different meanings based on the context, typically implemented via magic methods.
Mutable vs Immutable
Mutable objects can be changed after creation, while immutable objects cannot; examples include lists (mutable) and tuples (immutable).
What is 'data hiding'?
A technique used to restrict access to certain details of an object, achieved using private/protected access modifiers.
What is a 'factory' method?
A method that returns an instance of a class, often used to encapsulate the creation of objects.
What is 'method chaining'?
A technique that allows multiple method calls in a single line by returning `self` in each method.
What is the 'iterator' pattern?
A design pattern that provides a way to access elements of a collection sequentially without exposing its underlying representation.
What is a 'proxy' pattern?
A design pattern where a class represents the functionality of another class, typically used to control access or add functionality.
What is 'covariance and contravariance'?
Concepts in type systems that describe how type substitutability works in inheritance hierarchies, particularly in method return types and parameter types.
Free forever. No credit card needed.
Ready to study Python 3 — OOP & Advanced Topics?
Free forever. No credit card needed.