Python: Access Control(attribute and method)
Python does access control differently. Let’s discuss access control in Python in depth-
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
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
A Python Set is unordered collection of Zero or more hashable unique object references.
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