-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.py
More file actions
75 lines (48 loc) · 1.61 KB
/
classes.py
File metadata and controls
75 lines (48 loc) · 1.61 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'''class Ball:
def __int__(self, color, size, weight):
self.color = color
self.size = size
self.weight = weight
beach_ball = Ball()
print(beach_ball)
print(f'My ball is {beach_ball.color} and weighs {beach_ball.weight} grams.')'''
class Ball:
def __init__(self, color, size, weight):
self.color = color
self.size = size
self.weight = weight
beach_ball = Ball('White', 45, 2.6)
print(beach_ball)
print(f'My ball is {beach_ball.color} and weighs {beach_ball.weight} grams.')
print(f'My ball weighs {beach_ball.weight} grams and {beach_ball.size} cm cube')
class Mammals:
def __init__(self, sound):
self.sound = sound
dog = Mammals('bark')
wolf = Mammals('howl')
print(f'Dogs {dog.sound} and wolves {wolf.sound} ')
class Ball:
def __init__(self, color, size, weight):
self.color = color
self.size = size
self.weight = weight
football = Ball('black and white', 25, 10)
basketball = Ball('orange', 25, 20)
print(f'Basketballs are {basketball.color} and footballs are {football.color}')
class Vehicles:
def __init__(self, make, brand, model):
self.brand = brand
self.model = model
self.type = make
def color():
return 'Ash'
class BMW(Vehicles):
def __init__(self, make, brand, model):
super().__init__(make, brand, model)
def drive(self):
return True
car = Vehicles('Sedan', 'BMW', 'X1')
print(f'The car dealership is selling {car.brand} {car.model}')
new_car = BMW('X1', 'SUV', 'BMW')
car_color = color()
print(f'My new car is {car_color} and it\'s an {new_car.brand}')