OOP
Here you'll find some examples for object oriented programming with python.
Tesla Class
class Tesla:# static vars (apply to all objects that are instantiated)def __init__(self, x, y):self.x_coordinate = xself.y_coordinate = ydef move_tesla(self, x, y):self.x_coordinate = xself.y_coordinate = ydef will_crash(self, truck):""" (tuple) --> booltruck is 2 units away from tesla then crash"""x_diff = abs(self.x_coordinate - truck[0])y_diff = abs(self.y_coordinate - truck[1])return x_diff <=2 and y_diff <=2