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

Examples Let’s start with a simple function definition and usage- Output: Required Parameters Output: Optional Parameters Output: Return Value We can return some value at any point of the function. The return value can be received by assigning the function call to a variable. WARNING The function immediately stops executing further, when it reaches a … Read more

Python: Dictionary [Data Type]

Dictionary in Python is a collection of key/value pairs. Dictionaries use keys(labels) to store item/value references, instead of numbered index. Python Dictionary is a unordered and mutable collection of Zero(0) or more key/value pairs. Only hashable objects can be used as key in a Dictionary. Dictionary items are not ordered, and are not stored in … Read more