diff --git "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" index fe0df5951..31cc8aee1 100644 --- "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" +++ "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" @@ -11,3 +11,8 @@ Введите ваш возраст: 45 Ваши данные для входа в аккаунт: имя - Василий, пароль - vas, возраст - 45 """ + +a = input('Впиши слово: ') +b = int(input('Впиши цифру: ')) + +print(a, ' ', b, ' ') diff --git "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" index 840e3fa00..44c058c8b 100644 --- "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" +++ "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" @@ -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}') diff --git "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" index 0c08706fd..6a528ee97 100644 --- "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" +++ "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" @@ -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) diff --git "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_4.py" "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_4.py" index 9acac6dd3..ca0d905c1 100644 --- "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_4.py" +++ "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_4.py" @@ -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) diff --git "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_5.py" "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_5.py" index 51682803e..e1ab60376 100644 --- "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_5.py" +++ "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_5.py" @@ -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('Организация не прибыльна') diff --git "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_6.py" "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_6.py" index 3c46df32d..c8f5aa623 100644 --- "a/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_6.py" +++ "b/\320\243\321\200\320\276\320\272 1. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_6.py" @@ -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} день') diff --git "a/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" "b/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" index 6d54d9904..205f9769e 100644 --- "a/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" +++ "b/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_1.py" @@ -28,3 +28,33 @@ 8 10 12 14 16 18 """ + + +class Matrix: + def __init__(self, matrix_of_list): + self.matrix_of_list = matrix_of_list + + def __add__(self, other): + my_list_3 = [] + for i in range(0, len(self.matrix_of_list)): + my_list_4 = [] + for j in range(0, len(self.matrix_of_list[0])): + my_list_4.append(self.matrix_of_list[i][j] + other.matrix_of_list[i][j]) + my_list_3.append(my_list_4) + self.matrix_of_list = my_list_3 + return Matrix(self.matrix_of_list) + + def __str__(self): + for i in self.matrix_of_list: + for j in i: + print(j, end=" ") + print() + return "" + + +matrix_1 = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) +matrix_2 = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) +print(matrix_1) +print(matrix_2) +matrix_3 = matrix_1 + matrix_2 +print(matrix_3) diff --git "a/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" "b/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" index e66508458..3d06bc488 100644 --- "a/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" +++ "b/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_2.py" @@ -25,3 +25,34 @@ Два класса: абстрактный и Clothes """ + +from abc import ABC, abstractmethod + + +class Absclothes(ABC): + @abstractmethod + def coat(self): + pass + + @abstractmethod + def suit(self): + pass + + +class Clothes(Absclothes): + def __init__(self, v, h): + self.v = v + self.h = h + + def coat(self): + return round(self.v / 6.5 + 0.5, 1) + + @property + def suit(self): + return round(2 * self.h + 0.3, 1) + + +clothes = Clothes(17, 5) +print(f'Расход ткани на пальто = {clothes.coat()}') +print(f'Расход ткани на костюм = {clothes.suit}') +print(f'Общий расход = {clothes.coat() + clothes.suit}') diff --git "a/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" "b/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" index 417212ff5..79095a0f5 100644 --- "a/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" +++ "b/\320\243\321\200\320\276\320\272 7. \320\237\321\200\320\260\320\272\321\202\320\270\321\207\320\265\321\201\320\272\320\276\320\265 \320\267\320\260\320\264\320\260\320\275\320\270\320\265/task_3.py" @@ -100,3 +100,67 @@ *****\n *****\n *****\n *****\n *****\n *****\n **********\n **********\n ***** """ + + +class Cell: + def __init__(self, quantity): + self.quantity = int(quantity) + + def __str__(self): + return f'({self.quantity})' + + def __add__(self, other): + return f'Сумма клеток = {str(Cell(self.quantity + other.quantity))}' + + def __sub__(self, other): + if (self.quantity - other.quantity) > 0: + return f'Разность клеток = {Cell(int(self.quantity - other.quantity))}' + return f'Разность отрицательна, поэтому операция не выполняется' + + def __mul__(self, other): + return f'Умножение клеток = {Cell(int(self.quantity * other.quantity))}' + + def __truediv__(self, other): + return f'Деление клеток = {Cell(round(self.quantity // other.quantity))}' + + def make_order(self, cells_count): + row = '' + for _ in range(int(self.quantity / cells_count)): + row += f'{"*" * cells_count}\\n ' + row += f'{"*" * (self.quantity % cells_count)}' + return row + + +print("Создаем объекты клеток") +cell1 = Cell(30) +cell2 = Cell(25) + +cell3 = Cell(10) +cell4 = Cell(15) + +print() + +print("Складываем") +print(cell1 + cell2) + +print() + +print("Вычитаем") +print(cell2 - cell1) +print(cell4 - cell3) + +print() + +print("Умножаем") +print(cell2 * cell1) + +print() + +print("Делим") +print(cell1 / cell2) + +print() + +print("Организация ячеек по рядам") +print(cell1.make_order(5)) +print(cell2.make_order(10))