Python 3 — OOP & Advanced Topics

Preview35 cardsTechnology

Term

Class

Click card to reveal

1 / 6
👋 Tap = flip

All Terms (35)

Class

A blueprint for creating objects, containing attributes and methods.

Preview

Object

An instance of a class with specific values for attributes.

Preview

Inheritance

A mechanism where a new class can inherit attributes and methods from an existing class.

Preview

Encapsulation

The bundling of data and methods that operate on the data within a single unit or class.

Preview

Polymorphism

The ability to present the same interface for different data types.

Preview
Sign up to unlock

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.

Sign up to unlock

__init__

The constructor method in a class, initializing object attributes.

Sign up to unlock

Method Overloading

A concept where two or more methods in the same class have the same name but different parameters. (Limited support in Python)

Sign up to unlock

Method Overriding

Defining a method in a subclass with the same name and parameters as in the parent class, replacing the parent's method.

Sign up to unlock

What is a 'decorator' in Python?

A function that modifies the behavior of another function or method, usually defined with the `@decorator_name` syntax.

Sign up to unlock

@staticmethod

A decorator that defines a method in a class that does not operate on an instance or class itself.

Sign up to unlock

@classmethod

A decorator that defines a method that operates on the class itself, not on an instance.

Sign up to unlock

Self

A reference to the current instance of the class, used to access variables and methods.

Sign up to unlock

What is Multiple Inheritance?

A feature where a class can inherit attributes and methods from more than one parent class.

Sign up to unlock

MRO (Method Resolution Order)

The order in which base classes are searched when executing a method, typically using the C3 linearization algorithm.

Sign up to unlock

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.

Sign up to unlock

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.

Sign up to unlock

Inheritance Hierarchy

The structure of classes connected through inheritance, forming a tree.

Sign up to unlock

What is the purpose of the `super()` function?

To call methods from a parent class, often used to extend the behavior of inherited methods.

Sign up to unlock

Abstract Base Class (ABC)

A class that cannot be instantiated and often includes abstract methods that must be implemented by subclasses.

Sign up to unlock

What is a 'singleton' pattern?

A design pattern that restricts the instantiation of a class to a single object.

Sign up to unlock

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.

Sign up to unlock

Interface

A class that defines methods that must be created within any child classes built from the interface.

Sign up to unlock

What is the use of `__repr__` method?

To provide an official string representation of an object, often used for debugging.

Sign up to unlock

Dynamic Typing

A feature where the type of a variable is interpreted at runtime, allowing flexibility in Python.

Sign up to unlock

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.

Sign up to unlock

Namespace

A container that provides a scope to identifiers such as variables, functions, classes, etc.

Sign up to unlock

What is 'operator overloading'?

A feature that allows the same operator to have different meanings based on the context, typically implemented via magic methods.

Sign up to unlock

Mutable vs Immutable

Mutable objects can be changed after creation, while immutable objects cannot; examples include lists (mutable) and tuples (immutable).

Sign up to unlock

What is 'data hiding'?

A technique used to restrict access to certain details of an object, achieved using private/protected access modifiers.

Sign up to unlock

What is a 'factory' method?

A method that returns an instance of a class, often used to encapsulate the creation of objects.

Sign up to unlock

What is 'method chaining'?

A technique that allows multiple method calls in a single line by returning `self` in each method.

Sign up to unlock

What is the 'iterator' pattern?

A design pattern that provides a way to access elements of a collection sequentially without exposing its underlying representation.

Sign up to unlock

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.

Sign up to unlock

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.

Sign up free to unlock all 30 cards

Free forever. No credit card needed.

Ready to study Python 3 — OOP & Advanced Topics?

Free forever. No credit card needed.