Skip to content

Instantly share code, notes, and snippets.

@betterdatascience
Created November 13, 2020 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betterdatascience/6618859be9e01673a559992abe08a0a3 to your computer and use it in GitHub Desktop.
Save betterdatascience/6618859be9e01673a559992abe08a0a3 to your computer and use it in GitHub Desktop.
003_oop
class Car:
def __init__(self, brand, color, plate):
self.brand = brand
self.color = color
self.plate = plate
def start(self):
return f'{self.color} {self.brand} started!'
@staticmethod
def stop():
return 'All systems stop!'
def _check(self):
return 'Private method'
def __str__(self):
return f'Brand: {self.brand}, Color: {self.color}, Plate: {self.plate}'
__repr__ = __str__
cars = [Car(brand='Audi', color='Black', plate='XYXY-123'),
Car(brand='BMW', color='Purple', plate='QWER-321')]
print(cars[0])
print(cars[0].start())
print(cars[0].stop())
print(cars[0]._check())
print(cars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment