Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions task_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import time


class TrafficLight:
__color = ["Красный", "Желтый", "Зеленый"]

def running(self):
for el in self.__color:
print(el)
if el == "Красный" or el == "Зеленый":
time.sleep(7)
if el == "Желтый":
time.sleep(2)


a = TrafficLight()
a.running()
12 changes: 12 additions & 0 deletions task_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Road:

def __init__(self, length, width):
self._length = length
self._width = width

def weight(self, base_weight, depth):
return self._width * self._length * base_weight * depth


road_1 = Road(20, 5000)
print(road_1.weight(25, 5))
29 changes: 29 additions & 0 deletions task_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Worker:

def __init__(self, name, surname, position, wage, bonus):
self.name = name
self.surname = surname
self.position = position
self._income = {"wage": wage, "bonus": bonus}


class Position(Worker):

def __init__(self, name, surname, position, wage, bonus):
super().__init__(name, surname, position, wage, bonus)

def get_full_name(self):
return f"{self.name} {self.surname}"

def get_total_income(self):
return sum(self._income.values())


director = Position("Иван", "Иванов", "директор", 100000, 10000)
work = Position("Петров", "Петр", "работник", 10000, 0)

print(director.get_full_name())
print(director.get_total_income())

print(work.get_full_name())
print(work.get_total_income())
75 changes: 75 additions & 0 deletions task_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import random


class Car:

def __init__(self, name, color, is_police):
self.speed = int(random.random() * 120)
self.color = color
self.name = name
self.is_police = is_police

def go(self):
print("Машина поехала")

def stop(self):
print("Машина остановилась")

def turn(self, direction):
print(f"Машина повернула {direction}")

def show_speed(self):
return self.speed


class TownCar(Car):

def __init__(self, name, color):
Car.__init__(self, name, color, False)

def show_speed(self):
if self.speed > 60:
print(f"Привышение скорость")
return self.speed


class SportCar(Car):

def __init__(self, name, color):
super().__init__(name, color, False)


class WorkCar(Car):

def __init__(self, name, color):
super().__init__(name, color , False)

def show_speed(self):
if self.speed > 40:
print(f"Привышение скорости")
return self.speed


class PoliceCar(Car):

def __init__(self, name, color):
super().__init__(name, color, True)


town = TownCar("Жигули", "Черный")
sport = SportCar("Aуди", "Красный")
work = WorkCar("Трактор", "Черный")
police = PoliceCar("Лада", "Синий")

list_auto = [town, sport, work, police]

for el in list_auto:
print(el.name)
print(el.color)
print(el.speed)
print(el.is_police)
el.go()
el.turn("налево")
print(el.show_speed())
el.stop()
print("==============")
40 changes: 40 additions & 0 deletions task_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Stationery:

def __init__(self, title):
self.title = title

def draw(self):
print("Запуск отрисовки")


class Pen(Stationery):

def __init__(self):
super().__init__("Pen")

def draw(self):
print("Пишу ручкой")


class Pencil(Stationery):

def __init__(self):
super().__init__("Pencil")

def draw(self):
print("Рисую карандашом")


class Handle(Stationery):

def __init__(self):
super().__init__("Handle")

def draw(self):
print("Подчеркивая маркером")


list_station = [Stationery("Канцелярская принадлежность"), Handle(), Pencil(), Pen()]

for el in list_station:
el.draw()