Skip to content

Instantly share code, notes, and snippets.

class Elevator:
def __init__(self, bottom, top):
self.bottom = bottom
self.top = top
self.floor = bottom
def floor_up(self):
if self.floor < self.top:
self.floor += 1
print("Elevator at floor", self.floor)
class Car:
def __init__(self, registration_number, max_speed):
self.registration_number = registration_number
self.max_speed = max_speed
self.current_speed = 0
self.travelled_distance = 0
car = Car("ABC-123", 142)
print("Registration:", car.registration_number)
class Car:
def __init__(self, registration_number, max_speed):
self.registration_number = registration_number
self.max_speed = max_speed
self.current_speed = 0
self.travelled_distance = 0
# Demo
car = Car("ABC-123", 142)
print("Registration:", car.registration_number)