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


def circle_draw(x, y, r, color):

turtle.up()
turtle.goto(x, y - r)
turtle.down()
turtle.fillcolor(color)
turtle.begin_fill()
turtle.circle(r, 360)
turtle.end_fill()

return


class TrafficLight:
__color = ['Red', 'Yellow', 'Green']

def running(self):

while True:
circle_draw(15, -55, 15, 'white')
circle_draw(15, -20, 15, 'white')
circle_draw(15, 15, 15, TrafficLight.__color[0])
time.sleep(7)
circle_draw(15, 15, 15, 'white')
circle_draw(15, -20, 15, TrafficLight.__color[1])
circle_draw(15, -55, 15, 'white')
time.sleep(2)
circle_draw(15, 15, 15, 'white')
circle_draw(15, -20, 15, 'white')
circle_draw(15, -55, 15, TrafficLight.__color[2])
time.sleep(5)


tl = TrafficLight()
tl.running()
12 changes: 12 additions & 0 deletions T9_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Road:
def __init__(self, length, width):
self._l = length
self._w = width

def my_weight(self):
sum_w = self._l * self._w * (25/1000) * (5/100)
print(f'Масса асфальта, необходимого для покрытия всего дорожного полотна длиной {self._l} метров и шириной {self._w} метров составляет {sum_w} тонн.')


road1 = Road(100, 500)
road1.my_weight()
23 changes: 23 additions & 0 deletions T9_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Worker:

def __init__(self, name, surname, position, wage, bonus):
self.n = name
self.s = surname
self.p = position
self._income = {'wage': wage, 'bonus': bonus}
self.w = wage
self.b = bonus


class Position(Worker):
def get_full_name(self):
print(f'{self.n} {self.s}')

def get_total_income(self):
tot = self._income.get('wage') + self._income.get('bonus')
print(tot)


person = Position('Иван', 'Иванович', 'стажер', 20000, 5000)
person.get_full_name()
person.get_total_income()
75 changes: 75 additions & 0 deletions T9_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
class Car:
def __init__(self, speed, color, name, is_police=False):
self.s = speed
self.c = color
self.n = name
self.p = bool(is_police)

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

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

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

def show_speed(self):
print(f'Скорость автомобиля равна {self.s} км/ч')


class TownCar(Car):
def show_speed(self):
if self.s > 60:
print('Вы превысили скорость')
print(f'Скорость автомобиля равна {self.s} км/ч')


class SportCar(Car):
pass


class WorkCar(Car):
def show_speed(self):
if self.s > 40:
print('Вы превысили скорость')
print(f'Скорость автомобиля равна {self.s} км/ч')


class PoliceCar(Car):
pass


mazda = TownCar(65, 'red', 'ZZ')
mazda.go()
mazda.stop()
mazda.turn('право')
mazda.show_speed()
print(mazda.p)

volga = WorkCar(35, 'blue', '07')
volga.go()
volga.stop()
volga.turn('лево')
volga.show_speed()
print(volga.c)
print(volga.p)

ferrari = SportCar(120, 'yellow', 'F1')
ferrari.go()
ferrari.stop()
ferrari.turn('право')
ferrari.show_speed()
print(ferrari.c)
print(ferrari.s)
print(ferrari.p)

ford = PoliceCar(60, 'green', 'focus', True)
ford.go()
ford.stop()
ford.turn('право')
ford.show_speed()
print(ford.c)
print(ford.s)
print(ford.p)
31 changes: 31 additions & 0 deletions T9_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Stationery:
def __init__(self, title):
self.t = title

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


class Pen(Stationery):
def draw(self):
print('Толщина линии равна 0.5 мм')


class Pencil(Stationery):
def draw(self):
print('Карандаш остро заточен')


class Handle(Stationery):
def draw(self):
print('Маркер засох')


item_1 = Pen('parker')
item_1.draw()

item_2 = Pencil('bic')
item_2.draw()

item_3 = Handle('attache')
item_3.draw()