{}
run-icon
main.py
# Define the Vehicle class class Vehicle: def __init__(self, color, brand, model): self.color = color # Attribute for color self.brand = brand # Attribute for brand self.model = model # Attribute for model # Start Method for Vehicle def start(self): print(f"The {self.color} {self.brand} {self.model} is starting.") # Stop Method for Vehicle def stop(self): self.start() # Calling another method print(f"The {self.color} {self.brand} {self.model} is stopping.") # Creating two Car objects of the Vehicle class car1 = Vehicle("red", "Mercedes Benz", "Cabriolet") car2 = Vehicle("yellow", "Lamborghini", "Coupe") # Calling the methods of the Vehicle class to execute Car1 object car1.start() car1.stop() # Calling the methods of the Vehicle class to execute Car2 object car2.start() car2.stop()
Output