1/20
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Object-Oriented Programming (OOP)
A method of structuring a program by bundling related properties and behaviors into individual objects.
Class
A blueprint for creating objects.
Instance
An object that belongs to a class.
__init__() Method
Executed when a class is initiated; used to assign values to the properties of an object or perform other operations needed in the creation of an object.
self Parameter
A reference to the current instance of the class, used to access the variables that belong to the class.
Modify Object Properties
Changing the value of an object's property.
Delete Object Properties
Removing an object's property using the del keyword.
Methods
Functions that belong to the object.
Function
Doesn't need any object and is independent.
Method vs Function
A method is called by the object's name, while a function can be directly called by its name.
Creating Objects
The process of instantiating a class to create an object.
Deleting Objects
The process of removing an object from memory.
Object Properties
Attributes associated with an object, such as name, age, and address.
Object Behaviors
Operations that an object can perform, such as walking, talking, and sending emails.
Syntax for Deleting Property
del
Example of an Object
An object could represent a person with properties like a name, age, and address.
Example of an Email Object
An email object could have properties like a recipient list, subject, and body.
Accessing Class Variables
Using the self parameter to bind attributes with the given arguments.
Functionality of Methods
Methods operate on the data in a class.
First Parameter of Class Functions
The first parameter of any function in the class is self, but any other name can be used.
Real-World Modeling
OOP models real-world entities as software objects that have data and can perform operations.