-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathpractice_10.py
61 lines (46 loc) · 1.13 KB
/
practice_10.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Vehicle
# Attributes:
# max_speed
# colour
# Methods:
# move
class Vehicle:
def __init__(self, max_speed, colour):
self.max_speed = max_speed
self.colour = colour
def move(self):
print('I am moving.')
# Car
# Attribute:
# max_speed
# colour
# fuel
# Methods:
# move
# stay
class Car(Vehicle):
def __init__(self, fuel, max_speed, colour):
self.fuel = fuel
super().__init__(max_speed, colour)
def move(self):
print(f'Car is moving at {self.max_speed}.')
lada = Car('gasoline', 120, 'yellow')
# Bicycle
# Attributes:
# number_of_wheels
# colour
# max_speed
# Methods:
# move
# freestyle
class Bicycle(Vehicle):
def __init__(self, colour, max_speed, number_of_wheels):
super().__init__(max_speed, colour)
self.number_of_wheels = number_of_wheels
self.__number_of_passengers = 1
def freestyle(self):
print('I am freestyling.')
stels = Bicycle('yellow', 30, 2)
print(stels.colour)
stels.move()
stels.freestyle()