Data Engineering

Advanced Python for Data Engineering

OOP, decorators, generators, context managers, typing, async/await, modules, virtual environments

25 interview questionsยท
Junior
1

What is a class in Python?

Answer

A class is a blueprint that defines the structure and behavior of objects. It encapsulates data (attributes) and functions (methods) that operate on that data. Classes allow creating multiple instances sharing the same structure but with different values, which is fundamental to object-oriented programming.

2

What is the role of the __init__ method in a Python class?

Answer

The __init__ method is the constructor of a Python class. It is automatically called when creating a new instance and allows initializing the object's attributes with specific values. This method always receives self as its first parameter, which references the instance being created.

3

What is the difference between an instance method and a class method in Python?

Answer

An instance method receives self and operates on a specific instance, while a class method (decorated with @classmethod) receives cls and operates on the class itself. Class methods are useful for creating factory methods or modifying class attributes shared by all instances.

4

What is a decorator in Python?

5

How to create a decorator that accepts arguments?

+22 interview questions

Master Data Engineering for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free