OOP Flashcards
Class
A template for an instance of an object
Instance
An object constructed using the class
Attribute
A characteristic of an object
Method
A callable function defined in the class
Also an attribute
A mini function that can change the values of attributes
Encapsulation
Controls access to the values of the attribues , prevents unauthorised access to them
Inheritance
Allows a class to inherit methods and atributes from a parent class.
The class that inherits is called the child class (or sub class)
What does self refer to
Represents the instance of a class
what does init do
Is short for initialisation
Used to set initial values for a class variable
Also refered to as a constructor
Get and set method
Class Myclass():
def set_val(self, val): self.value = val def get_val(self): return self.value