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
5 changes: 5 additions & 0 deletions Урок 1. Практическое задание/task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
Введите ваш возраст: 45
Ваши данные для входа в аккаунт: имя - Василий, пароль - vas, возраст - 45
"""

a = input('Впиши слово: ')
b = int(input('Впиши цифру: '))

print(a, ' ', b, ' ')
8 changes: 8 additions & 0 deletions Урок 1. Практическое задание/task_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
Введите время в секундах: 3600
Время в формате ч:м:с - 1.0 : 60.0 : 3600
"""

seconds = int(input('Впиши секунды: '))
hours = seconds // 3600
seconds = seconds - hours * 3600
minutes = seconds // 60
seconds = seconds - minutes * 60

print(f'Time: {hours:02}:{minutes:02}:{seconds:02}')
8 changes: 8 additions & 0 deletions Урок 1. Практическое задание/task_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
Введите число n: 3
n + nn + nnn = 369
"""

nubmer = input('Введите число: ')

second_number = nubmer+nubmer
third_number = nubmer+nubmer+nubmer

answer = int(nubmer) + int(second_number) + int(third_number)
print('Ответ: ', answer)
11 changes: 11 additions & 0 deletions Урок 1. Практическое задание/task_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
Ведите целое положительное число: 123456789
Самая большая цифра в числе: 9
"""

number = int(input('Введите положительное число: '))

max = number % 10

while number > 0:
if number % 10 > max:
max = number % 10
number = number // 10

print('Максимальная цифра: ', max)
13 changes: 13 additions & 0 deletions Урок 1. Практическое задание/task_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@
Введите численность сотрудников фирмы: 10
Прибыль фирмы в расчете на одного сотрудника = 50.0
"""

revenue = float(input('Введите доход: '))
expenses = float(input('Введите издержки: '))

if revenue > expenses:
profit = revenue - expenses
print('Организация прибыльна')
employees = int(input('Введите число сотрудников: '))
print(f'Прибыль на сотрудника: {(profit/employees):.2f}')
elif revenue == expenses:
print('Доходы равны расходам')
else:
print('Организация не прибыльна')
11 changes: 11 additions & 0 deletions Урок 1. Практическое задание/task_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@
6-й день: 3,22
Ответ: на 6-й день спортсмен достиг результата — не менее 3 км.
"""

a = float(input('Расстояние первого дня: '))
b = float(input('Цель: '))
d = 1

while a < b:
a = a * 1.1
d += 1
print(f"День {d}: {a:.2f} км")

print(f'Цель достигнута на {d} день')
28 changes: 28 additions & 0 deletions Урок 6. Практическое задание/task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,31 @@

Проверить работу примера, создав экземпляр и вызвав описанный метод.
"""


from time import sleep


class TrafficLight:
__color = ['# Красный #', '# Желтый #', '# Зеленый #', '# Зеленый-3x #', '# Желтый - красный / ночной режим #']

def running(self):
i = 0
while i < 5:
print(f'Светофор переключается ...\n '
f'{TrafficLight.__color[i]}')
if i == 0:
sleep(7)
elif i == 1:
sleep(2)
elif i == 2:
sleep(7)
elif i == 3:
sleep(1)
elif i == 4:
sleep(2)
i += 1
print(f'Цикл выполнен без ошибок!')

t = TrafficLight()
t.running()
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено

16 changes: 16 additions & 0 deletions Урок 6. Практическое задание/task_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@

Например: 20м*5000м*25кг*0.05м = 125000 кг = 125 т
"""


class Road:
weight = 25
thickness = 5

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

def asphalt_weight(self):
return self.weight * self.thickness * self._length * self._width / 1000


my_road = Road(5000, 20)
print(f'Масса асфальта = {my_road.asphalt_weight()} тонн')
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено

24 changes: 24 additions & 0 deletions Урок 6. Практическое задание/task_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,27 @@
П.С. попытайтесь добить вывода информации о сотруднике также через перегрузку __str__
__str__(self) - вызывается функциями str, print и format. Возвращает строковое представление объекта.
"""


class Worker:
def __init__(self, name, surname_f, surname, position, wage, bonus):
self.name = name
self.surname_f = surname_f
self.surname = surname
self.position = position
self._income = {"wage": wage, "bonus": bonus} #_private

class Position(Worker):
def __init__(self, name, surname_f, surname, position, wage, bonus):
super().__init__(name, surname_f, surname, position, wage, bonus)

def get_full_name(self):
return self.name + ' ' + self.surname_f + ' ' + self.surname

def get_total_income(self):
return f'{sum(self._income.values())}'

a = Position('Путин', 'Александр', 'Николаевич', 'Президент Российской Империи', 100000, 500)
print(f'ФИО : {a.get_full_name()}')
print(f'Должность : {a.position}')
print(f'Доход : {a.get_total_income()}')
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено

99 changes: 99 additions & 0 deletions Урок 6. Практическое задание/task_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,102 @@
Выполните доступ к атрибутам, выведите результат.
Выполните вызов методов и также покажите результат.
"""


class Car:

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

def go(self):
print(f'Начало движения {self.name}')

def stop(self):
print(f'Остановка {self.name} ')

def turn(self, direction):
print(f'{self.name} поворачивает {direction}')

def show_speed(self, speed):
print(f'Скорость движения автомобиля - {self.speed}')
if self.speed > self.max_speed and not self.is_police:
print(f'Автомобиль {self.name} превысил скорость')


class TownCar(Car):
def __init__(self, speed, color, name, is_police):
super().__init__(speed, color, name, is_police)

def show_speed(self, speed):
self.speed = speed
super().show_speed(self.speed)


class SportCar(Car):
def __init__(self, speed, color, name, is_police):
super().__init__(speed, color, name, is_police)

def show_speed(self, speed):
self.speed = speed
super().show_speed(self.speed)

class WorkCar(Car):
def __init__(self, speed, color, name, is_police):
super().__init__(speed, color, name, is_police)

def show_speed(self, speed):
self.speed = speed
super().show_speed(self.speed)


class PoliceCar(Car):
def __init__(self, speed, color, name, is_police):
super().__init__(speed, color, name, is_police)

def show_speed(self, speed):
self.speed = speed
super().show_speed(self.speed)


emobil = TownCar(60, 'Желтый', 'Ёмобиль', False)
emobil.go()
emobil.show_speed(50)
emobil.turn('налево')
emobil.go()
emobil.show_speed(70)
emobil.stop()
print()

toyota = WorkCar(80, 'Серый', 'Toyota', False)
toyota.go()
toyota.show_speed(60)
toyota.turn('направо')
toyota.go()
toyota.turn('направо')
toyota.show_speed(90)
toyota.stop()
toyota.go()
toyota.show_speed(50)
toyota.turn('налево')
print()

lada_sport = SportCar(90, 'Зелёный', 'Lada Kalina Sport', False)
lada_sport.go()
# subaru.show_speed(110)
lada_sport.turn('направо')
lada_sport.turn('направо')
lada_sport.go()
lada_sport.show_speed(180)
lada_sport.show_speed(210)
lada_sport.show_speed(230)
print()

lada_vesta = PoliceCar(110, 'Белый', 'Lada Vesta', True)
lada_vesta.go()
lada_vesta.show_speed(110)
lada_vesta.show_speed(150)
lada_vesta.stop()
print()
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено

37 changes: 37 additions & 0 deletions Урок 6. Практическое задание/task_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,40 @@
Для каждого из классов метод должен выводить уникальное сообщение.
Создать экземпляры классов и проверить, что выведет описанный метод для каждого экземпляра.
"""


class Stationery:

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

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


class Pen(Stationery):

def draw(self):
return f'{self.title} - Запуск отрисовки'


class Pencil(Stationery):

def draw(self):
return f'{self.title} - Запуск отрисовки'


class Handle(Stationery):

def draw(self):
return f'{self.title} - Запуск отрисовки'


pen = Pen('Ручка')
print(pen.draw())

pencil = Pencil('Карандаш')
print(pencil.draw())

handle = Handle('Маркер')
print(handle.draw())
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено