Objected-orientated programming Flashcards
Objects:
Instances of classes that encapsulate data and behaviour.
Classes:
Blueprint or template for creating objects.
Inheritance:
A mechanism for creating a new class that is a modified version of an existing class.
Polymorphism:
The ability of objects to take on multiple forms, often achieved through method overloading and overriding.
Encapsulation:
Bundling of data and methods that operate on the data within a single unit (class).
Attributes (Properties):
Variables that store data in a class.
Methods (Functions):
Functions that perform actions within a class.
class example
(Creation)
class Car:
def __init__(self, make, model):
self.make = make
self.model = model
def display_info(self): print(f"{self.make} {self.model}")
What is a setter
A setter is a special type of method that sets one of the attributes equal to a special value
What is a Getter method
A getter is a special type of method that obtains the value of one of the attributes of the object.