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.

Python: Boolean [Data Type]

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

Python: Class and Object

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

Python: Mathematical Operators

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

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

Python: Function

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