Python: Decorator
A decorator is a function that accepts a function and returns a function. We can perform the additional steps of operation(that we want to add before/after the original function), in the implementation of the decorator.
A decorator is a function that accepts a function and returns a function. We can perform the additional steps of operation(that we want to add before/after the original function), in the implementation of the decorator.
Python does access control differently. Let’s discuss access control in Python in depth-
Getters and setters work as the entry point for managing and manipulating data for an object of a class. In this article, we are discussing the getter, setter, and deleter for the property of a Python class.
We can use a floating point number to represent a decimal number. In Python we can represent 3 types of floating values- NOTES All these 3 types are immutable. That means when any of the above types of data is created in memory, it is never changed. Reassigning a new value to any of the … Read more
There are 2 built-in Boolean objects in Python- If we convert any other data type to Boolean, it will be either True or False. Create Boolean We can use the “bool” function to create a boolean. If no param is provided then it returns false- Output: Or we can just assign a Boolean value – … Read more
An object in Python(and in general OOP) is a collection of data, and the behavior associated with the different aspects of the object. Object-Oriented Programming(OOP) refers to, objects being the primary focus while programming and modeling all real-world entities as objects. So when we analyze a problem, we need to identify 2 things- Class is … Read more
Operator Description + Addition – Subtraction * Multiplication / Division // Floor division ** Power % Reminder Addition Output: Subtraction Output: Multiplication Output: Division Output: Floor Division Output: Reminder Output: Power Output: Precedence of Mathematical Operators Not all operators have the same precedence. Based on the operators’ priority/precedence, the evaluation sequence will change. Let’s check … Read more
Python package is a collection of modules in a directory. To tell Python, that this directory should be considered a package, we have to add a file named __init__.py Python package is a directory that contains a __init__.py file and a set of modules. The name of the directory is considered as the name of … Read more
Functions enable us to isolate and encapsulate a certain piece of code into its own block. And then it can be used in different places of the program without repeating the same code over and over again. NOTES In Python, functions are first-class objects(entities), so a function can be- Let’s see how we can define … Read more
A Python Set is unordered collection of Zero or more hashable unique object references.