Skip to content

Instantly share code, notes, and snippets.

@keobox
Last active November 6, 2021 08:56
Show Gist options
  • Save keobox/2f9ac9d5c231f1d1a983568d39a12ec2 to your computer and use it in GitHub Desktop.
Save keobox/2f9ac9d5c231f1d1a983568d39a12ec2 to your computer and use it in GitHub Desktop.
Car database
class Car:
def __init__(self, name, color, hp):
self.name = name
self.color = color
self.hp = hp
car_db = {"alboreto": Car("Ferrari", "Red", 2000), "senna": Car("McLaren", "White", 2000)}
assert car_db["alboreto"].name == "Ferrari"
assert car_db["senna"].name == "McLaren"
ferrari = car_db["alboreto"]
assert ferrari.color == "Red"
print("OK")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment