Python is a hight level programming language that supports Object Oriented Programming. The concepts one should be familiar is Class, Objects and instances, methods or functions, etc. Thus tutorial is aimed to introduce OOP using Python to audience that are already familiar with these concepts using any other OOP language such as Java, C++, etc
#The __init__ function. The constructor of the class.
#The “self” variable is needed by default even if there are no variables to be passed.
def __init__(self, theBrand, theModel):
self.theBrand = theBrand
self.theModel = theModel
def speed(self, mySpeed):
print(“My ” + self.theBrand + ” ” + self.theModel + ” can go at a speed of ” + str(mySpeed))
def theType(self, theType):
print(“I am of the type ” + str(theType))
myCar = MyVehicle(‘Honda’, ‘Accord’)
myNextCar = MyVehicle(‘Jeep’, ‘Wrangler’)