This commit is contained in:
adii1823
2021-10-28 16:58:30 +05:30
parent 028f6992f4
commit ff85709895
19 changed files with 161 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# let's define the class Bike
class Bike:
def __init__(self, colour, frame_material):
self.colour = colour
self.frame_material = frame_material
def brake(self):
print("Braking!")
# let's create a couple of instances
red_bike = Bike('Red', 'Carbon fiber')
blue_bike = Bike('Blue', 'Steel')
# let's inspect the objects we have, instances of the Bike class.
print(red_bike.colour) # prints: Red
print(red_bike.frame_material) # prints: Carbon fiber
print(blue_bike.colour) # prints: Blue
print(blue_bike.frame_material) # prints: Steel
# let's brake!
red_bike.brake() # prints: Braking!