The document discusses object-oriented programming (OOP) concepts in Python. It defines OOP, classes, objects, attributes, methods, inheritance, and polymorphism. Key points include: - OOP uses classes as templates for objects with identities, states, and behaviors. - Classes define attributes and methods. Objects are instances of classes. - Inheritance allows classes to inherit attributes and methods from parent classes. There are different types of inheritance. - Polymorphism means the same message can be displayed in different forms. Abstraction and encapsulation hide unnecessary details from users.
OOP Object-oriented programming (OOP)involves programming using objects. An object represents an entity in the real-world that can be distinctly identified. An object consists of identity, state, and behavior. โข Identity: It gives a unique name to an object. โข State: It reflects the properties of an object. โข Behavior: It reflects the response of an object with other objects.
3.
Characteristics of OOPs โขOOPs uses a bottom-up approach. โข The program is divided into objects. โข OOPs uses access modifiers. โข OOPs is more secure than procedural languages. โข Objects can move freely within member functions.
4.
Classes Class is atemplate/blue-print for real-world entities Properties Behavior โข Color โข Cost โข Battery Life โข Make Calls โข Watch Videos โข Play Games
Attributes and Methods color cost PlayGame Make Call Attributes Methods Methods are functions defined inside a class. They are invoked by objects to perform actions on other objects. Attributes are defined within a class and outside any method. Attributes define the characteristics of any object.
Creating a classwith Constructor init method acts as the constructor __init__ is a method that is automatically called when memory is allocated to a new object. For invoking in build parameter with object , self is used .
Definitions : Abstraction isthe property by virtue of which only the essential details are displayed to the user. Encapsulation is a process of binding data members and member functions into a single unit. Encapsulation hides the state of a structured data object inside a class, preventing unauthorized access to an unauthorized person. Polymorphism is a Greek word that means many shaped. Polymorphism is the ability of a message to be displayed in more than one form.