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
14 changes: 14 additions & 0 deletions #1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from time import sleep


class TrafficLight:
__color = [('красный', 2), ('желтый', 2), ('зеленый', 3)]

def running(self):
for a, b in self.__color:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошо! давай улучшим немного и обзовём переменные как light_color и light_time

print(a)
sleep(b)


c = TrafficLight()
c.running()
14 changes: 14 additions & 0 deletions #2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Road:
def __init__(self, length, width):
self._length = length
self._width = width

def mass(self, thickness, mass_sm):
return self._length*self._width*thickness*mass_sm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

помни про форматирование



Road_1 = Road(20, 5000)
print(Road_1.mass(25, 5))



23 changes: 23 additions & 0 deletions #3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
income = {'worker1': {'wage': 10000, 'bonus': 5000}, 'worker2': {'wage': 20000, 'bonus': 5000}}


class Worker:
def __init__(self, name, surname, position):
self.name = name
self.surname = surname
self.position = position
self._income = income[position]


class Position(Worker):
def get_full_name(self):
print(f'Имя: {self.name}\n'
f'Фамилия: {self.surname}')

def get_total_income(self):
print(f'Общий доход {self._income["wage"]+self._income["bonus"]}')


a = Position("Иван", "Иванов", 'worker1')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут тоже обзови переменную более информативно

a.get_full_name()
a.get_total_income()
54 changes: 54 additions & 0 deletions #4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class Car:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

отлично!

def __init__(self, speed, color, name, is_police=False):
self.speed = speed
self.color = color
self.name = name
self.is_police = is_police

def go(self, speed=0):
self.speed += speed
if self.speed == 0:
self.speed = int(input('Введите скорость: '))
print(f'Машина поехала со скоростью {self.speed}')

def stop(self):
print('Машина остановилась')
self.speed = 0

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

def show_speed(self):
print(f'Текущая скорость {self.speed}')


class TownCar(Car):
def show_speed(self):
print(f'Текущая скорость {self.speed}')
if self.speed > 60:
print('Скорость превышена!')


class WorkCar(Car):
def show_speed(self):
print(f'Текущая скорость {self.speed}')
if self.speed > 40:
print('Скорость превышена!')


class SportCar(Car):
pass


class PoliceCar(Car):
is_police = True


TownCar1 = TownCar(61, 'black', 'Tree')
TownCar1.go(10)
TownCar1.show_speed()
print(TownCar1.is_police)
print(TownCar1.color)
TownCar1.stop()
TownCar1.go(30)
TownCar1.show_speed()
31 changes: 31 additions & 0 deletions #5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Stationery:
def __init__(self, title):
self.title = title

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


class Pen(Stationery):
def draw(self):
print('Запуск отрисовки ручкой')


class Pencil(Stationery):
def draw(self):
print('Запуск отрисовки карандашом')


class Handle(Stationery):
def draw(self):
print('Запуск отрисовки маркером')


a = Stationery('Рисунок1')
a.draw()
b = Pen('Рисунок2')
b.draw()
c = Pencil('Рисунок3')
c.draw()
d = Handle('Рисунок4')
d.draw()