Классы в Python

Пример программы
class Car:
    def __init__(self, speed, color):
        self.speed = speed
        self.color = color

    def beep(self):
        print("BEEEEEEP")

    def say_speed(self):
        print("My speed is " + str(self.speed))

    def say_color(self):
        print("My color is " + self.color)


porshe = Car(120, "black")
porshe.beep()

bmw = Car(110, "red")
bmw.beep()
bmw.say_speed()
bmw.say_color()


class Player:
    def __init__(self, nick):
        self.nick = nick

    def say_nick(self):
        print ("My nick is " + self.nick)


player_1 = Player("Vinni_pooh")
player_1.say_nick()
Made on
Tilda