You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
""" In Python, constructors are special methods used to initialize objects. The constructor method is called __init__()
Basic Constructor
The __init__() method is automatically called when an instance of a class is created. It allows the class to initialize the attributes of the object. """
class Car:
def __init__(self, brand, model, price, milage):
self.brand = brand # These are the class variables
self.model = model
self.price = price
self.milage = milage
def start_car(self):
print(self.brand+" car having model as "+self.model+" has started")
def stop_car(self):
print(self.brand+" car having model as "+self.model+" has stoped")