-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMethods.py
More file actions
35 lines (22 loc) · 749 Bytes
/
Methods.py
File metadata and controls
35 lines (22 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Car:
def __init__(self, brand, model, year):
self.brand = brand
self.model = model
self.year = year
def display_details(self):
print(f"Car Brand: {self.brand}")
print(f"Model: {self.model}")
print(f"Year: {self.year}")
def start_engine(self):
print(f"The {self.brand} {self.model}'s engine has started!")
def stop_engine(self):
print(f"The {self.brand} {self.model}'s engine has stopped.")
car1 = Car("Toyota", "Innova", 2020)
car2 = Car("Hyundai", "Creta", 2023)
car1.display_details()
car1.start_engine()
car1.stop_engine()
print()
car2.display_details()
car2.start_engine()
car2.stop_engine()