Python Archive
Creating dynamic variables: Dynamic variables get memory inside object. We create dynamic variables from constructor using ‘self’. In the above code, every object get initialized with same set of values only. How can we set …
Access Modifiers: Access modifiers are used to set permissions to access the data. Python supports 3 access modifiers. Private( _ _var) Protected ( _var) Public ( var) Note: Protected members can be discussed with Inheritance …
Private members: A member definition preceded by _ _ is called private member. One object(class) cannot access the private members of another object directly. Note: A class itself can access the private members. Accessing private …
Accessing private variables from another class: One class cannot access the private information from another class directly. A class(object) is allowed to share(send or receive) the private data in communication. Communication between objects is possible …
Bank Application with operations withdraw() and deposit():
Encapsulation: The concept of protecting object information. By implementing Encapsulation rules, an object behaves like real world entity. Rules: Class is public – Object is visible to other objects in communication. Variables are private – …
Inheritance: Defining an object by re-using the functionality of existing object Inheritance includes: Accessing the functionality of existing Object. Adding new functionality to object Update existing object functionality(if required) The main advantage of inheritance in …
Single Inheritance: In parent-child relation, we can access the functionality of Parent through child. We cannot access Child functionality using Parent. Accessing static members in Parent and Child as follows: Accessing dynamic functionality in Parent-Child …
Method overriding: Defining a method in the Child class with same name and same set of arguments of Parent class method. When two methods in Parent and Child with the same identity, it gives the …
Implementing inheritance with more than level is called Multi Level Inheritance. We can access the complete functionality of all objects using Child object reference.