Which Python feature would you use to modify the behavior of a function or method?
- Decorators
- Encapsulation
- Inheritance
- Polymorphism
In Python, decorators are used to modify the behavior of functions or methods. They allow you to add functionality to existing code without modifying its structure. Decorators are often used for tasks like logging, authentication, and more.
Loading...
Related Quiz
- Which function in Matplotlib is primarily used to create bar plots?
- Which keyword is used to import a module in Python?
- How would you optimize a Python function that is found to be CPU-bound during profiling?
- You have a base class Vehicle and a derived class Car. The base class has a method start(). If you want to add additional functionalities to the start() method specifically for the Car class without affecting the base class, what should you do?
- You are debugging a program that should print numbers from 1 to 10, but it's getting stuck and printing the same number indefinitely. What could be a possible reason?