python init

Posted by w3diy - 8 months ago

Init In Python

class Car(object):
"""
blueprint for car
"""
def __init__(self, yearm, type, condition, toprank):
self.type = type
self.condition = condition
self.toprank = toprank
self.yearm = yearm
def start(self):
print("Good Luck started")
def stop(self):
print("You car stopped")
def accelarate(self):
print("On the way accelarating...")
"accelarator functionality here"
def change_gear(self, gear_type):
print("and then step by step gear changed")
" gear related functionality here"
Now that we have created the objects, let’s move on to create the individual cars in the game.
maruthi_suzuki = Car("i10", "wagnore", "pasero", 60)
audi = Car("A6", "red", "audi", 80)