Object Oriented Programming
Class Declaration & Structure in Python
Classes are a blueprint for creating individual objects that contain the general characteristics of a defined object type. A modifier may or may not be used to declare a class.
class ClassName: #fields, constructor public_member #can be accessed from outside the class #cannot be accessed from outside the class, shown with two underscores __private_member
The class body contains constructors for initializing new objects, declarations for the fields that provide the state of the class and its objects, and methods to implement the behaviour of the class and its objects.
class Bike(object): #constructor def __init__(self, gear, speed): self.gear = gear self.speed = speed def apply_brake(decrement): self.speed -= decrement def speed_up(increment): self.speed += increment