From a846e3484d457f90dca4ac0b52e23041b8ee4faf Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sun, 10 Oct 2021 12:24:42 +0300 Subject: [PATCH 01/92] Add homework1.py --- homework1.py | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 homework1.py diff --git a/homework1.py b/homework1.py new file mode 100644 index 0000000..cb0430b --- /dev/null +++ b/homework1.py @@ -0,0 +1,95 @@ +""" +Индекс в названии функции соответствует номеру задания +""" +""" +Для демонстрации работы функций следуйте инструкции после запуска программы +""" + + +def num1(): + a = None + b = 1 + c = 1.7 + print(f'a = {a}, b = {b}, c = {c}') + a = input(f'a = ') + b = input(f'b = ') + c = input(f'c = ') + print(f'a = {a}, b = {b}, c = {c}') + + +def num2(): + t = int(input(f'Введите время в секундах: ')) + ts = t%60 + tm = int(t/60)%60 + th = int(t/3600) + print(f'{th}:{tm}:{ts}') + + +def num3(): + n = input('Введите число: ') + nn = str(n+n) + nnn = str(n+n+n) + a = int(n) + b = int(nn) + c = int(nnn) + print(int(a + b + c)) + + +def num4(): + n = int(input(f'Введите целое положительное число: ')) + var = 0 + while n != 0: + m = n % 10 + if m > var: + var = m + n = n // 10 + print(f'Наибольшая цифра в числе: {var}') + + +def num5(): + p = int(input('Введите сумму выручки: ')) + c = int(input('Введите сумму издержек: ')) + if p > c: + print('Фиксируем прибыль') + print(f'Рентабельность: {(p - c) / p}') + num = int(input('Введите число работников: ')) + print(f'Прибыль на сотрудника компании составляет: {(p - c) / num}') + else: + print('Терпим убытки') + + +def num6(): + a = float(input('Рекорд: ')) + b = float(input('Цель: ')) + count = 0 + i = 1 + while a <= b: + print(f'{i}-ый день: {a:.{3}f}') + a = a + a * 10 / 100 + count += 1 + i += 1 + print(f'Результат {a:.{3}f} км будет достигнут на {count} день') + + +answer = '' +while answer != 'n': + answer = input('Начнем? (y/n): ') + if answer == 'y': + q = '' + while q != ' ': + q = input('Введите номер задания или пробел: ') + if q == '1': + num1() + elif q == '2': + num2() + elif q == '3': + num3() + elif q == '4': + num4() + elif q == '5': + num5() + elif q == '6': + num6() + else: + print('Некорректный ввод') + From f500be74ba0dff4dfe9ce873015e456184a989ce Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sun, 10 Oct 2021 12:39:23 +0300 Subject: [PATCH 02/92] made some changes --- homework1.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homework1.py b/homework1.py index cb0430b..4ebea71 100644 --- a/homework1.py +++ b/homework1.py @@ -1,4 +1,7 @@ """ +Выполнил: Агеев Георгий (BigData 1795) +""" +""" Индекс в названии функции соответствует номеру задания """ """ From 041fe50ecc00e1e42c6d607c5e892684b1ea645a Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sun, 10 Oct 2021 12:55:11 +0300 Subject: [PATCH 03/92] full complect --- .idea/.gitignore | 3 +++ .idea/GU_BigData_1795.iml | 8 ++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ 6 files changed, 35 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/GU_BigData_1795.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/GU_BigData_1795.iml b/.idea/GU_BigData_1795.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/GU_BigData_1795.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..84958fa --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1648bd0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 5f5676f70e31c0d0bc15a19f5bdbc0aece68ccdd Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sat, 23 Oct 2021 16:47:26 +0300 Subject: [PATCH 04/92] new homework --- homework4.py | 0 lesson4/homework4.py | 110 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 homework4.py create mode 100644 lesson4/homework4.py diff --git a/homework4.py b/homework4.py new file mode 100644 index 0000000..e69de29 diff --git a/lesson4/homework4.py b/lesson4/homework4.py new file mode 100644 index 0000000..09d63c3 --- /dev/null +++ b/lesson4/homework4.py @@ -0,0 +1,110 @@ +from functools import reduce +from itertools import count, cycle +from sys import argv +from random import randrange + + +""" +Номер 1 +""" +name, hours, money_in_hour, prize = argv +salary = int(money_in_hour) * int(hours) + int(prize) +print(salary) + + +def num2(i=0): + new_list = [] + len_list = randrange(20) + my_gen = [randrange(20) for i in range(len_list)] + print(my_gen) + try: + while i != (len_list - 1): + if my_gen[i] < my_gen[i + 1]: + new_list.append(my_gen[i + 1]) + i += 1 + except IndexError: + print(new_list) + else: + print(new_list) + + +def num3(): + gen = (i for i in range(20, 241) if i % 20 == 0 or i % 21 == 0) + return gen + + +def num4(): + len_gen = randrange(20) + gen = [randrange(20) for i in range(len_gen)] + print(gen) + new_gen = [el for el in gen if gen.count(el) == 1] + return new_gen + + +def num5(): + gen = [i for i in range(100, 1001) if i%2 == 0] + print(gen) + return reduce(lambda a, b: a * b, gen) + + +def num6_1(a, b, c): + for i in count(a, b): + if i >= c: + break + yield i + + +def num6_2(my_list, steps, counter=0): + for i in cycle(my_list): + """ + steps*len(my_list) - число шагов в одном обороте "cycle()" + """ + if counter >= steps*len(my_list): + break + yield i + counter += 1 + + +def num7(n, a=1): + for i in range(1, n+1): + a *= i + yield a + + +""" +main(): +""" +q = ' ' +while q != '': + q = input('Введите номер задания или нажмите ENTER: ') + if q == '1': + print(f'Заработная плата: {salary}') + elif q == '2': + num2() + elif q == '3': + for el in num3(): + print(el) + elif q == '4': + print(num4()) + elif q == '5': + print(num5()) + elif q == '6.1': + a = int(input('Стартовое число: ')) + b = int(input('Шаг: ')) + c = int(input('Предел: ')) + for el in num6_1(a, b, c): + print(el) + elif q == '6.2': + my_list = [] + el = input('Введите элемент списка или ENTER: ') + while el != '': + my_list.append(el) + el = input('Введите элемент списка или ENTER: ') + print('Оборот - полное прохождение "cycle()" по аргументу-списку') + steps = int(input('Введите число оборотов "cycle()": ')) + for el in num6_2(my_list, steps, 0): + print(el) + elif q == '7': + n = int(input('Найти фаториал числа: ')) + for el in num7(n): + print(el) From 85714cbe67e1415c55a953c646b1eeb27b3ca077 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:48:47 +0300 Subject: [PATCH 05/92] Delete .gitignore --- .idea/.gitignore | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml From 92c43d0f0fc2a2ebfa1aaa69facc93daa47ad3c9 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:48:54 +0300 Subject: [PATCH 06/92] Delete GU_BigData_1795.iml --- .idea/GU_BigData_1795.iml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/GU_BigData_1795.iml diff --git a/.idea/GU_BigData_1795.iml b/.idea/GU_BigData_1795.iml deleted file mode 100644 index d0876a7..0000000 --- a/.idea/GU_BigData_1795.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From db745c2e096b73d506bb8c76e6d9400e26ffd3e6 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:49:00 +0300 Subject: [PATCH 07/92] Delete misc.xml --- .idea/misc.xml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .idea/misc.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 84958fa..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From dca6fdd9cb95e04bcb4d4c78c024a99216442a8f Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:49:09 +0300 Subject: [PATCH 08/92] Delete vcs.xml --- .idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 714e1fee7957df40bcdb6281c5f363a9c901a503 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:49:25 +0300 Subject: [PATCH 09/92] Delete homework1.py --- homework1.py | 98 ---------------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 homework1.py diff --git a/homework1.py b/homework1.py deleted file mode 100644 index 4ebea71..0000000 --- a/homework1.py +++ /dev/null @@ -1,98 +0,0 @@ -""" -Выполнил: Агеев Георгий (BigData 1795) -""" -""" -Индекс в названии функции соответствует номеру задания -""" -""" -Для демонстрации работы функций следуйте инструкции после запуска программы -""" - - -def num1(): - a = None - b = 1 - c = 1.7 - print(f'a = {a}, b = {b}, c = {c}') - a = input(f'a = ') - b = input(f'b = ') - c = input(f'c = ') - print(f'a = {a}, b = {b}, c = {c}') - - -def num2(): - t = int(input(f'Введите время в секундах: ')) - ts = t%60 - tm = int(t/60)%60 - th = int(t/3600) - print(f'{th}:{tm}:{ts}') - - -def num3(): - n = input('Введите число: ') - nn = str(n+n) - nnn = str(n+n+n) - a = int(n) - b = int(nn) - c = int(nnn) - print(int(a + b + c)) - - -def num4(): - n = int(input(f'Введите целое положительное число: ')) - var = 0 - while n != 0: - m = n % 10 - if m > var: - var = m - n = n // 10 - print(f'Наибольшая цифра в числе: {var}') - - -def num5(): - p = int(input('Введите сумму выручки: ')) - c = int(input('Введите сумму издержек: ')) - if p > c: - print('Фиксируем прибыль') - print(f'Рентабельность: {(p - c) / p}') - num = int(input('Введите число работников: ')) - print(f'Прибыль на сотрудника компании составляет: {(p - c) / num}') - else: - print('Терпим убытки') - - -def num6(): - a = float(input('Рекорд: ')) - b = float(input('Цель: ')) - count = 0 - i = 1 - while a <= b: - print(f'{i}-ый день: {a:.{3}f}') - a = a + a * 10 / 100 - count += 1 - i += 1 - print(f'Результат {a:.{3}f} км будет достигнут на {count} день') - - -answer = '' -while answer != 'n': - answer = input('Начнем? (y/n): ') - if answer == 'y': - q = '' - while q != ' ': - q = input('Введите номер задания или пробел: ') - if q == '1': - num1() - elif q == '2': - num2() - elif q == '3': - num3() - elif q == '4': - num4() - elif q == '5': - num5() - elif q == '6': - num6() - else: - print('Некорректный ввод') - From 3cbe562e26b156221594ac8f867743b947b0e268 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:49:41 +0300 Subject: [PATCH 10/92] Delete modules.xml --- .idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 1648bd0..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 2df76dce712ceb2716369622adc5e39e3a4aa836 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:49:51 +0300 Subject: [PATCH 11/92] Delete profiles_settings.xml --- .idea/inspectionProfiles/profiles_settings.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file From 722346dd4517866eed2586e81f655e0954f075af Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sat, 23 Oct 2021 16:52:16 +0300 Subject: [PATCH 12/92] update --- lesson4/homework4.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lesson4/homework4.py b/lesson4/homework4.py index 09d63c3..412b469 100644 --- a/lesson4/homework4.py +++ b/lesson4/homework4.py @@ -4,6 +4,18 @@ from random import randrange +""" +Индекс в названии функции соответствует номеру задания +""" +""" +Для демонстрации работы функций следуйте инструкции после запуска программы +""" +""" +ВНИМАНИЕ! +Для 6-го задания предусмотрены варианты ввода: 6.1 - для обратоки слова, 6.2 - для обработки нескольких слов +""" + + """ Номер 1 """ From 4d6d50c913c449314bd284604e52b5bbb321dccd Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sat, 23 Oct 2021 16:55:42 +0300 Subject: [PATCH 13/92] update --- lesson4/homework4.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lesson4/homework4.py b/lesson4/homework4.py index 412b469..22700b9 100644 --- a/lesson4/homework4.py +++ b/lesson4/homework4.py @@ -11,8 +11,7 @@ Для демонстрации работы функций следуйте инструкции после запуска программы """ """ -ВНИМАНИЕ! -Для 6-го задания предусмотрены варианты ввода: 6.1 - для обратоки слова, 6.2 - для обработки нескольких слов +Для 6-го задания предусмотрены варианты ввода: 6.1, 6.2 """ From 0a469eecfbfd895ac574cf2e860191e43f5984c2 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sun, 24 Oct 2021 11:07:16 +0300 Subject: [PATCH 14/92] updates --- .idea/BigData.iml | 12 + .idea/misc.xml | 2 +- .idea/modules.xml | 2 +- .idea/workspace.xml | 82 +++++++ README.md | 1 - lesson1/.idea/.gitignore | 0 .../.idea/homework1.iml | 0 .../inspectionProfiles/profiles_settings.xml | 6 + lesson1/.idea/misc.xml | 4 + lesson1/.idea/modules.xml | 8 + lesson1/.idea/workspace.xml | 53 +++++ homework1.py => lesson1/homework1.py | 13 +- {.idea => lesson2/.idea}/.gitignore | 0 lesson2/.idea/homework2.iml | 8 + .../inspectionProfiles/profiles_settings.xml | 6 + lesson2/.idea/misc.xml | 4 + lesson2/.idea/modules.xml | 8 + lesson2/homework2.py | 206 ++++++++++++++++++ lesson3/.idea/.gitignore | 3 + lesson3/.idea/BigData.iml | 8 + .../inspectionProfiles/profiles_settings.xml | 6 + lesson3/.idea/misc.xml | 4 + lesson3/.idea/modules.xml | 8 + lesson3/homework3.py | 170 +++++++++++++++ lesson4/.idea/BigData.iml | 10 + .../inspectionProfiles/profiles_settings.xml | 6 + lesson4/.idea/misc.xml | 4 + lesson4/.idea/modules.xml | 8 + lesson4/.idea/vcs.xml | 6 + lesson4/.idea/workspace.xml | 49 +++++ 30 files changed, 687 insertions(+), 10 deletions(-) create mode 100644 .idea/BigData.iml create mode 100644 .idea/workspace.xml delete mode 100644 README.md create mode 100644 lesson1/.idea/.gitignore rename .idea/GU_BigData_1795.iml => lesson1/.idea/homework1.iml (100%) create mode 100644 lesson1/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 lesson1/.idea/misc.xml create mode 100644 lesson1/.idea/modules.xml create mode 100644 lesson1/.idea/workspace.xml rename homework1.py => lesson1/homework1.py (93%) rename {.idea => lesson2/.idea}/.gitignore (100%) create mode 100644 lesson2/.idea/homework2.iml create mode 100644 lesson2/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 lesson2/.idea/misc.xml create mode 100644 lesson2/.idea/modules.xml create mode 100644 lesson2/homework2.py create mode 100644 lesson3/.idea/.gitignore create mode 100644 lesson3/.idea/BigData.iml create mode 100644 lesson3/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 lesson3/.idea/misc.xml create mode 100644 lesson3/.idea/modules.xml create mode 100644 lesson3/homework3.py create mode 100644 lesson4/.idea/BigData.iml create mode 100644 lesson4/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 lesson4/.idea/misc.xml create mode 100644 lesson4/.idea/modules.xml create mode 100644 lesson4/.idea/vcs.xml create mode 100644 lesson4/.idea/workspace.xml diff --git a/.idea/BigData.iml b/.idea/BigData.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/.idea/BigData.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 84958fa..096b0f3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 1648bd0..964f100 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..8aa7cb3 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1634885950324 + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 68abb7b..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# GU_BigData_1795 \ No newline at end of file diff --git a/lesson1/.idea/.gitignore b/lesson1/.idea/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.idea/GU_BigData_1795.iml b/lesson1/.idea/homework1.iml similarity index 100% rename from .idea/GU_BigData_1795.iml rename to lesson1/.idea/homework1.iml diff --git a/lesson1/.idea/inspectionProfiles/profiles_settings.xml b/lesson1/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson1/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson1/.idea/misc.xml b/lesson1/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/lesson1/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson1/.idea/modules.xml b/lesson1/.idea/modules.xml new file mode 100644 index 0000000..b3868b4 --- /dev/null +++ b/lesson1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson1/.idea/workspace.xml b/lesson1/.idea/workspace.xml new file mode 100644 index 0000000..f342665 --- /dev/null +++ b/lesson1/.idea/workspace.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + 1634490503476 + + + + \ No newline at end of file diff --git a/homework1.py b/lesson1/homework1.py similarity index 93% rename from homework1.py rename to lesson1/homework1.py index 4ebea71..0af32c9 100644 --- a/homework1.py +++ b/lesson1/homework1.py @@ -1,5 +1,5 @@ """ -Выполнил: Агеев Георгий (BigData 1795) +Выполнил: Агеев Георгий (AI 1781) """ """ Индекс в названии функции соответствует номеру задания @@ -14,9 +14,9 @@ def num1(): b = 1 c = 1.7 print(f'a = {a}, b = {b}, c = {c}') - a = input(f'a = ') - b = input(f'b = ') - c = input(f'c = ') + a = input('a = ') + b = input('b = ') + c = input('c = ') print(f'a = {a}, b = {b}, c = {c}') @@ -30,8 +30,8 @@ def num2(): def num3(): n = input('Введите число: ') - nn = str(n+n) - nnn = str(n+n+n) + nn = n+n + nnn = n+n+n a = int(n) b = int(nn) c = int(nnn) @@ -95,4 +95,3 @@ def num6(): num6() else: print('Некорректный ввод') - diff --git a/.idea/.gitignore b/lesson2/.idea/.gitignore similarity index 100% rename from .idea/.gitignore rename to lesson2/.idea/.gitignore diff --git a/lesson2/.idea/homework2.iml b/lesson2/.idea/homework2.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/lesson2/.idea/homework2.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson2/.idea/inspectionProfiles/profiles_settings.xml b/lesson2/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson2/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson2/.idea/misc.xml b/lesson2/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/lesson2/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson2/.idea/modules.xml b/lesson2/.idea/modules.xml new file mode 100644 index 0000000..de00548 --- /dev/null +++ b/lesson2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson2/homework2.py b/lesson2/homework2.py new file mode 100644 index 0000000..ec8835d --- /dev/null +++ b/lesson2/homework2.py @@ -0,0 +1,206 @@ +""" +Выполнил: Агеев Георгий (AI 1781) +""" +""" +Индекс в названии функции соответствует номеру задания +""" +""" +Для демонстрации работы функций следуйте инструкции после запуска программы +""" + + +def num1(): + my_list = [] + type_list = [] + el = input('Введите элемент списка: ') + while el != '': + my_list.append(el) + if el.isdigit() is True: + el = int(el) + """ + Если не int, то str либо и есть str, либо float, либо содержит признаки обоих типов + """ + else: + """ + Проверим str на соответсвие float + str является float, если выполняются три признака + Плавающая точка - первый признак типа float, + Второй - она только одна + """ + check = el.split('.') + """ + Точка делит строку на две части, тогда длина списка "check" должна быть строго равна 2 + Если это не так, то тип данных str + """ + if len(check) == 2: + """ + Третий признак - обе части списка должны состоять только из цифр + Если это не так, то тип данных str + """ + if check[0].isdigit() and check[1].isdigit(): + el = float(el) + else: + break + else: + el = str(el) + type_list.append(type(el)) + el = input('Введите элемент списка: ') + print(f'Исходный список: {my_list}') + print(f'Типовой список: {type_list}') + + +def num2(): + my_list = [] + el = input('Введите элемент списка: ') + while el != '': + my_list.append(el) + el = input('Введите элемент списка: ') + print(f'Исходный список: {my_list}') + i = 0 + while i < len(my_list): + if i == (len(my_list) - 1) and len(my_list) / 2 is not int: + break + """ + вариант через кортеж: + my_list[i], my_list[i+1] = my_list[i+1], my_list[i] + i += 2 + """ + a = my_list[i] + i += 1 + my_list[i - 1] = my_list[i] + my_list[i] = a + i += 1 + print(f'Результат: {my_list}') + + +def num3(): + do = '' + while do != '3': + do = input('Что использовать?\n1.Словарь\t2.Список\t3.Выход\n') + """ + Решение с помощью словаря + """ + if do == '1': + my_dict = {1: 'Jan', 2: 'Feb', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'Aug', 9: 'Sept', + 10: 'Oct', 11: 'Nov', 12: 'Dec'} + key = int(input('Введите номер месяца: ')) + if my_dict.get(key) == 12 or 1 or 2: + print(f'{my_dict.get(key)}, время года года - зима') + elif my_dict.get(key) == 3 or 4 or 5: + print(f'{my_dict.get(key)}, время года года - весна') + elif my_dict.get(key) == 6 or 7 or 8: + print(f'{my_dict.get(key)}, время года года - лето') + elif my_dict.get(key) == 9 or 10 or 11: + print(f'{my_dict.get(key)}, время года года - осень') + else: + print('Некорректный ввод') + """ + Решение с помощью списка + """ + elif do == '2': + four_seasons = ['Зима', 'Весна', 'Лето', 'Осень'] + key = int(input('Введите номер месяца: ')) + try: + print(four_seasons[key // 3]) + except IndexError: + print('Зима') + + +def num4(): + string = input('Введите строку: ') + my_list = string.split(' ') + for i in my_list: + print(f'{my_list.index(i) + 1}) {i[0:10]}') + + +def num5(): + my_list = [5, 5, 10, 4, 1, 4, 4, 6, 2, 6, 10, 7] + my_list.sort() + el = input('Введите элемент списка: ') + while el != '': + el = int(el) + try: + pos = my_list.index(el) + except ValueError: + my_list.append(el) + my_list.sort() + else: + my_list.insert(pos, el) + el = input('Введите элемент списка: ') + print(my_list) + my_list.reverse() + print(f'Рейтинговый список:\n{my_list}') + + +""" +"condition" - это функция для условия "if" в заданнии 6. +Она проходит по списку, элементами которого являются кортежи вида: (индекс, словарь), +запрашивает j-ый элемент списка, 1-ый элемент кортежа и переходит таким образом к работе со словарем. +Функцией "my_dict.setdefault(nom))" запрашивает значение, находящееся под ключ-переменной "nom" +и добавляет его в список значений "values". +Полученный список ("values") становится значением нового, локального, словаря "my_dict_local" +с ключом "nom". +В результате работы данной функции получаются словари следующего вида: +“название”: [“компьютер”, “принтер”, “сканер”], +“цена”: [20000, 6000, 2000], +“количество”: [5, 2, 7], +“ед”: [“шт.”] +""" + + +def condition(j, my_list, values, nom): + while j < len(my_list): + values.append(my_list[j][1].setdefault(nom)) + j += 1 + my_dict_local = {nom: values} + print(my_dict_local) + + +def num6(): + my_list = [] + i = 0 + do = '' + print('Выберите действие:') + while do != '3': + do = input('1.Добавить товар\t2.Выборка\t3.Выход\n') + if do == '1': + name = input('Наименование: ') + price = input('Цена: ') + quantity = input('Количество: ') + unit = input('Единица измерения: ') + my_dict = {'Наименование': name, 'Цена': price, 'Количество': quantity, 'ед.': unit} + my_tuple = (i + 1, my_dict) + i += 1 + my_list.append(my_tuple) + elif do == '2': + values = [] + j = 0 + do = input('1.Наименование\n2.Цена\n3.Количество\n4.ед.\n') + if do == '1': + condition(j, my_list, values, 'Наименование') + elif do == '2': + condition(j, my_list, values, 'Цена') + elif do == '3': + condition(j, my_list, values, 'Количество.') + elif do == '4': + condition(j, my_list, values, 'ед.') + + +""" +main(): +""" +q = ' ' +while q != '': + q = input('Введите номер задания или нажмите ENTER: ') + if q == '1': + num1() + elif q == '2': + num2() + elif q == '3': + num3() + elif q == '4': + num4() + elif q == '5': + num5() + elif q == '6': + num6() diff --git a/lesson3/.idea/.gitignore b/lesson3/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/lesson3/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lesson3/.idea/BigData.iml b/lesson3/.idea/BigData.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/lesson3/.idea/BigData.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson3/.idea/inspectionProfiles/profiles_settings.xml b/lesson3/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson3/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson3/.idea/misc.xml b/lesson3/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/lesson3/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson3/.idea/modules.xml b/lesson3/.idea/modules.xml new file mode 100644 index 0000000..964f100 --- /dev/null +++ b/lesson3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson3/homework3.py b/lesson3/homework3.py new file mode 100644 index 0000000..199520e --- /dev/null +++ b/lesson3/homework3.py @@ -0,0 +1,170 @@ +""" +Выполнил: Агеев Георгий (BigData 1795) +""" +""" +Индекс в названии функции соответствует номеру задания +""" +""" +Для демонстрации работы функций следуйте инструкции после запуска программы +""" +""" +ВНИМАНИЕ! +Для 6-го задания предусмотрены варианты ввода: 6.1 - для обратоки слова, 6.2 - для обработки нескольких слов +""" + + +def num1(a, b): + try: + print(a/b) + except ZeroDivisionError: + print('Деление на 0') + print('Попробуте еще раз!') + a = int(input('Числитель = ')) + b = int(input('Знаменатель = ')) + print(a / b) + return a/b + + +def num2(name, nom, born, city, email, number): + print(f'Имя: {name}\tФамилия: {nom}\tГод рождения: {born}\tГород: {city}\te-mail: {email}\tТелефон: {number}\n') + + +def num3(a, b, c, j): + my_list = [a, b, c] + """ + Определяю тип переменной: int или float + """ + for i in my_list: + if i.isdigit() is True: + i = int(i) + else: + check = i.split('.') + if len(check) == 2: + if check[0].isdigit() and check[1].isdigit(): + i = float(i) + my_list[j] = i + j += 1 + """ + Цикл на случай, если решение требует не использовать функцию ".sort()" + """ + """ + j = 0 + while j < 2: + if my_list[j] > my_list[j + 1]: + my_list[j + 1] = my_list[j] + else: + j += 1 + j += 1 + """ + my_list.sort() + print(my_list[1] + my_list[2]) + return my_list[1] + my_list[2] + + +def num4(x, y): + for i in range(abs(y)): + x *= x + print(1 / x) + return 1 / x + + +def num5(string, sum, j): + """ + Суммирование вводимых чисел до того, как попадется специальный символ "q" + """ + while string.count('q') == 0: + my_list = string.split(' ') + for i in my_list: + sum += int(i) + print(sum) + string = input('Введите числа через пробел: ') + string.count('q') + """ + Как только строка содержит специальный символ, происходит суммирование чисел перед ним - работа завершается + """ + my_list = string.split(' ') + while my_list[j] != 'q': + sum += int(my_list[j]) + j += 1 + print(sum) + + +""" +Вспомогательная функция к заданию "6", обрататывающая, по заданию, одно слово +""" + + +def helper(my_string, i): + alphabet = (('a', 'A'), ('b', 'B'), ('c', 'C'), ('d', 'D'), ('e', 'E'), + ('f', 'F'), ('g', 'G'), ('h', 'H'), ('i', 'I'), ('j', 'J'), + ('k', 'K'), ('l', 'L'), ('m', 'M'), ('n', 'N'), ('o', 'O'), + ('p', 'P'), ('q', 'Q'), ('r', 'R'), ('s', 'S'), ('t', 'T'), + ('u', 'U'), ('v', 'V'), ('w', 'W'), ('x', 'X'), ('y', 'Y'), ('z', 'Z')) + while my_string[0] != alphabet[i][0]: + i += 1 + print(alphabet[i][1] + my_string[1:]) + return alphabet[i][1] + my_string[1:] + + +""" +Здание 6.2. Например, вы ввели: aleksandra shapovalova + Результат: Aleksandra + Shapovalova + Aleksandra Shapovalova + Первые две строки отображаются в результате работы функции "helper" +""" + + +def num6(string): + """ + Список, чтобы собрать функцкцией .join() + """ + my_list = [] + """ + Работа функции "helper" над каждым словом строки, введенной пользователем + """ + for j in string.split(' '): + my_list.append(helper(j, 0)) + """ + Сброка получившегося списка в строку + """ + print(' '.join(my_list)) + return ' '.join(my_list) + + +""" +main(): +""" +q = ' ' +while q != '': + q = input('Введите номер задания или нажмите ENTER: ') + if q == '1': + a = int(input('Числитель = ')) + b = int(input('Знаменатель = ')) + num1(a, b) + elif q == '2': + name = input('Имя: ') + nom = input('Фамилия: ') + born = input('Год рождения: ') + city = input('Город: ') + email = input('e-mail: ') + number = input('Телефон: ') + num2(name, nom, born, city, email, number) + elif q == '3': + a = input('a = ') + b = input('b = ') + c = input('c = ') + num3(a, b, c, 0) + elif q == '4': + x = abs(float(input('Введите действительное положительное число: '))) + y = int(input('Введите целое отрицательное число: ')) + num4(x, y) + elif q == '5': + string = input('Введите числа через пробел: ') + num5(string, 0, 0) + elif q == '6.1': + my_string = input('Введите слово из маленьких латинских букв: ') + helper(my_string, 0) + elif q == '6.2': + string = input('Введите слова из маленьких латинских букв: ') + num6(string) diff --git a/lesson4/.idea/BigData.iml b/lesson4/.idea/BigData.iml new file mode 100644 index 0000000..f06d9bd --- /dev/null +++ b/lesson4/.idea/BigData.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/lesson4/.idea/inspectionProfiles/profiles_settings.xml b/lesson4/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson4/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson4/.idea/misc.xml b/lesson4/.idea/misc.xml new file mode 100644 index 0000000..2c92b24 --- /dev/null +++ b/lesson4/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson4/.idea/modules.xml b/lesson4/.idea/modules.xml new file mode 100644 index 0000000..964f100 --- /dev/null +++ b/lesson4/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson4/.idea/vcs.xml b/lesson4/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/lesson4/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lesson4/.idea/workspace.xml b/lesson4/.idea/workspace.xml new file mode 100644 index 0000000..05e0a1e --- /dev/null +++ b/lesson4/.idea/workspace.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1634843454449 + + + + \ No newline at end of file From ec8f1a820ea3db1c5e58553603325db6817b7d44 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Sun, 24 Oct 2021 11:31:40 +0300 Subject: [PATCH 15/92] last update --- lesson4/homework4.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lesson4/homework4.py b/lesson4/homework4.py index 22700b9..d599f29 100644 --- a/lesson4/homework4.py +++ b/lesson4/homework4.py @@ -4,6 +4,9 @@ from random import randrange +""" +Выполнил: Агеев Георгий BigData 1795 +""" """ Индекс в названии функции соответствует номеру задания """ From 04d5d958d9acd5de7eb70ed9c33636bb263774cb Mon Sep 17 00:00:00 2001 From: Elvirience Date: Thu, 28 Oct 2021 19:15:39 +0300 Subject: [PATCH 16/92] waiting more... --- lesson5/ex2.txt | 3 +++ lesson5/ex3.txt | 17 ++++++++++++++ lesson5/ex4.txt | 4 ++++ lesson5/homework5.py | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 lesson5/ex2.txt create mode 100644 lesson5/ex3.txt create mode 100644 lesson5/ex4.txt create mode 100644 lesson5/homework5.py diff --git a/lesson5/ex2.txt b/lesson5/ex2.txt new file mode 100644 index 0000000..46a4915 --- /dev/null +++ b/lesson5/ex2.txt @@ -0,0 +1,3 @@ +do did done +1 2 3 +Привет \ No newline at end of file diff --git a/lesson5/ex3.txt b/lesson5/ex3.txt new file mode 100644 index 0000000..6e04d5f --- /dev/null +++ b/lesson5/ex3.txt @@ -0,0 +1,17 @@ +Несветова 150000 +Адамов 98687 +Денисов 231185 +Рюрикович 127080 +Робертс 1000000 +Монтана 398400 +Тодд 580900 +О'Клай 497568 +Королев 352698 +Руккулус 19500 +Катрин 18668 +Агеев 3140329 +Басов 2000288 +Макушин 1400356 +Годес 190543 +Бирюков 32999 +Пискарев 400650 \ No newline at end of file diff --git a/lesson5/ex4.txt b/lesson5/ex4.txt new file mode 100644 index 0000000..48de98b --- /dev/null +++ b/lesson5/ex4.txt @@ -0,0 +1,4 @@ +One - 1 +Two - 2 +Three - 3 +Four - 4 \ No newline at end of file diff --git a/lesson5/homework5.py b/lesson5/homework5.py new file mode 100644 index 0000000..6185143 --- /dev/null +++ b/lesson5/homework5.py @@ -0,0 +1,56 @@ +""" +Агеев Георгий BigData 1795 +""" +""" +Добавлю две задачи и опишу 5-ую +""" +def num1(): + fin = open('ex1.txt', 'w', encoding='UTF-8') + data = input('Введите данные для записи в файл или пустую строку: ') + while data != '': + fin.write(data + '\n') + data = input('Введите данные для записи в файл или пустую строку: ') + fin.close() + + +def num2(lines=0, words=0): + fout = open('ex2.txt', 'r', encoding='UTF-8') + for i in fout.readlines(): + print(f"Число слов в строке {lines + 1}: {len(i.split())}") + lines += 1 + print(f'Число строк: {lines}') + fout.close() + + +def num3(i=0, count=0): + with open('ex3.txt', 'r', encoding='UTF-8') as fout: + for line in fout: + surname, salary = line.split() + i += int(salary) + if int(salary) < 20000: + print(surname) + count += 1 + print(f'Средняя величина дохода: {int(i/count)}') + + + +def num4(i=0): + fout = open('ex4.txt', 'r', encoding='UTF-8') + fin = open('ex4_in.txt', 'w', encoding='UTF-8') + my_list = ['Один', 'Два', 'Три', 'Четыре'] + for line in fout: + line = line.split(' - ') + line[0] = my_list[i] + new_line = ' - '.join(line) + fin.write(new_line) + i += 1 + fout.close() + fin.close() + + +def num5(i=0, sum=0): + with open('ex5.txt', 'r+', encoding='UTF - 8') as fin: + print('5 0 1 2 3 7 9 5 6 81 4 56 1', file=fin) + for i in fin.readline().split(): + sum += int(i) + print(sum) From d0b3b966a0146809c3b824ec966ae9ac0b1be195 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:17:07 +0300 Subject: [PATCH 17/92] Delete homework1.py --- lesson1/homework1.py | 97 -------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 lesson1/homework1.py diff --git a/lesson1/homework1.py b/lesson1/homework1.py deleted file mode 100644 index 0af32c9..0000000 --- a/lesson1/homework1.py +++ /dev/null @@ -1,97 +0,0 @@ -""" -Выполнил: Агеев Георгий (AI 1781) -""" -""" -Индекс в названии функции соответствует номеру задания -""" -""" -Для демонстрации работы функций следуйте инструкции после запуска программы -""" - - -def num1(): - a = None - b = 1 - c = 1.7 - print(f'a = {a}, b = {b}, c = {c}') - a = input('a = ') - b = input('b = ') - c = input('c = ') - print(f'a = {a}, b = {b}, c = {c}') - - -def num2(): - t = int(input(f'Введите время в секундах: ')) - ts = t%60 - tm = int(t/60)%60 - th = int(t/3600) - print(f'{th}:{tm}:{ts}') - - -def num3(): - n = input('Введите число: ') - nn = n+n - nnn = n+n+n - a = int(n) - b = int(nn) - c = int(nnn) - print(int(a + b + c)) - - -def num4(): - n = int(input(f'Введите целое положительное число: ')) - var = 0 - while n != 0: - m = n % 10 - if m > var: - var = m - n = n // 10 - print(f'Наибольшая цифра в числе: {var}') - - -def num5(): - p = int(input('Введите сумму выручки: ')) - c = int(input('Введите сумму издержек: ')) - if p > c: - print('Фиксируем прибыль') - print(f'Рентабельность: {(p - c) / p}') - num = int(input('Введите число работников: ')) - print(f'Прибыль на сотрудника компании составляет: {(p - c) / num}') - else: - print('Терпим убытки') - - -def num6(): - a = float(input('Рекорд: ')) - b = float(input('Цель: ')) - count = 0 - i = 1 - while a <= b: - print(f'{i}-ый день: {a:.{3}f}') - a = a + a * 10 / 100 - count += 1 - i += 1 - print(f'Результат {a:.{3}f} км будет достигнут на {count} день') - - -answer = '' -while answer != 'n': - answer = input('Начнем? (y/n): ') - if answer == 'y': - q = '' - while q != ' ': - q = input('Введите номер задания или пробел: ') - if q == '1': - num1() - elif q == '2': - num2() - elif q == '3': - num3() - elif q == '4': - num4() - elif q == '5': - num5() - elif q == '6': - num6() - else: - print('Некорректный ввод') From 023156fb350ea86aab3dd476f56ae7eb24f80904 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:17:17 +0300 Subject: [PATCH 18/92] Delete workspace.xml --- lesson1/.idea/workspace.xml | 53 ------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 lesson1/.idea/workspace.xml diff --git a/lesson1/.idea/workspace.xml b/lesson1/.idea/workspace.xml deleted file mode 100644 index f342665..0000000 --- a/lesson1/.idea/workspace.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - 1634490503476 - - - - \ No newline at end of file From f936612cbc2a797c58821f633d7d15400281f9c7 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:17:24 +0300 Subject: [PATCH 19/92] Delete modules.xml --- lesson1/.idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson1/.idea/modules.xml diff --git a/lesson1/.idea/modules.xml b/lesson1/.idea/modules.xml deleted file mode 100644 index b3868b4..0000000 --- a/lesson1/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From dd52ce46944bbc5b15ba2310bd056e88d7711eec Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:17:32 +0300 Subject: [PATCH 20/92] Delete misc.xml --- lesson1/.idea/misc.xml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lesson1/.idea/misc.xml diff --git a/lesson1/.idea/misc.xml b/lesson1/.idea/misc.xml deleted file mode 100644 index d56657a..0000000 --- a/lesson1/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 261fd2f528c0945ef307be51c6c5a050d2dbfee0 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:17:40 +0300 Subject: [PATCH 21/92] Delete homework1.iml --- lesson1/.idea/homework1.iml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson1/.idea/homework1.iml diff --git a/lesson1/.idea/homework1.iml b/lesson1/.idea/homework1.iml deleted file mode 100644 index d0876a7..0000000 --- a/lesson1/.idea/homework1.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From a5edea16db1ed1b1cb6e0fb82a24d62e829c2e06 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:17:54 +0300 Subject: [PATCH 22/92] Delete workspace.xml --- .idea/workspace.xml | 82 --------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 8aa7cb3..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1634885950324 - - - - - - - \ No newline at end of file From b4226bbe1cc1ac1462834b330c4be38a93c93d07 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:18:05 +0300 Subject: [PATCH 23/92] Delete modules.xml --- .idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 964f100..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 0cc2cf7c730cdff32a7ca7046e8fbdefa40c92a5 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:18:24 +0300 Subject: [PATCH 24/92] Delete BigData.iml --- .idea/BigData.iml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .idea/BigData.iml diff --git a/.idea/BigData.iml b/.idea/BigData.iml deleted file mode 100644 index 8b8c395..0000000 --- a/.idea/BigData.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file From 874fc08c8aac7f1691854e3d810ed0e2b35ce222 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:18:43 +0300 Subject: [PATCH 25/92] Delete misc.xml --- .idea/misc.xml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .idea/misc.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 096b0f3..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From fa25d66c27aa83fad1bfc6e746c4cfca10ed590e Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:18:50 +0300 Subject: [PATCH 26/92] Delete profiles_settings.xml --- lesson1/.idea/inspectionProfiles/profiles_settings.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lesson1/.idea/inspectionProfiles/profiles_settings.xml diff --git a/lesson1/.idea/inspectionProfiles/profiles_settings.xml b/lesson1/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/lesson1/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file From 37555d090203cafd46ad6d9dc756ae2caf995d14 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:18:56 +0300 Subject: [PATCH 27/92] Delete profiles_settings.xml --- lesson2/.idea/inspectionProfiles/profiles_settings.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lesson2/.idea/inspectionProfiles/profiles_settings.xml diff --git a/lesson2/.idea/inspectionProfiles/profiles_settings.xml b/lesson2/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/lesson2/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file From 51765245496be3c0854de4b25296c53b06557862 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:19:03 +0300 Subject: [PATCH 28/92] Delete modules.xml --- lesson2/.idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson2/.idea/modules.xml diff --git a/lesson2/.idea/modules.xml b/lesson2/.idea/modules.xml deleted file mode 100644 index de00548..0000000 --- a/lesson2/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From a628bec4f35183af22acd7487b5bb42188d89a2d Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:19:16 +0300 Subject: [PATCH 29/92] Delete homework2.py --- lesson2/homework2.py | 206 ------------------------------------------- 1 file changed, 206 deletions(-) delete mode 100644 lesson2/homework2.py diff --git a/lesson2/homework2.py b/lesson2/homework2.py deleted file mode 100644 index ec8835d..0000000 --- a/lesson2/homework2.py +++ /dev/null @@ -1,206 +0,0 @@ -""" -Выполнил: Агеев Георгий (AI 1781) -""" -""" -Индекс в названии функции соответствует номеру задания -""" -""" -Для демонстрации работы функций следуйте инструкции после запуска программы -""" - - -def num1(): - my_list = [] - type_list = [] - el = input('Введите элемент списка: ') - while el != '': - my_list.append(el) - if el.isdigit() is True: - el = int(el) - """ - Если не int, то str либо и есть str, либо float, либо содержит признаки обоих типов - """ - else: - """ - Проверим str на соответсвие float - str является float, если выполняются три признака - Плавающая точка - первый признак типа float, - Второй - она только одна - """ - check = el.split('.') - """ - Точка делит строку на две части, тогда длина списка "check" должна быть строго равна 2 - Если это не так, то тип данных str - """ - if len(check) == 2: - """ - Третий признак - обе части списка должны состоять только из цифр - Если это не так, то тип данных str - """ - if check[0].isdigit() and check[1].isdigit(): - el = float(el) - else: - break - else: - el = str(el) - type_list.append(type(el)) - el = input('Введите элемент списка: ') - print(f'Исходный список: {my_list}') - print(f'Типовой список: {type_list}') - - -def num2(): - my_list = [] - el = input('Введите элемент списка: ') - while el != '': - my_list.append(el) - el = input('Введите элемент списка: ') - print(f'Исходный список: {my_list}') - i = 0 - while i < len(my_list): - if i == (len(my_list) - 1) and len(my_list) / 2 is not int: - break - """ - вариант через кортеж: - my_list[i], my_list[i+1] = my_list[i+1], my_list[i] - i += 2 - """ - a = my_list[i] - i += 1 - my_list[i - 1] = my_list[i] - my_list[i] = a - i += 1 - print(f'Результат: {my_list}') - - -def num3(): - do = '' - while do != '3': - do = input('Что использовать?\n1.Словарь\t2.Список\t3.Выход\n') - """ - Решение с помощью словаря - """ - if do == '1': - my_dict = {1: 'Jan', 2: 'Feb', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'Aug', 9: 'Sept', - 10: 'Oct', 11: 'Nov', 12: 'Dec'} - key = int(input('Введите номер месяца: ')) - if my_dict.get(key) == 12 or 1 or 2: - print(f'{my_dict.get(key)}, время года года - зима') - elif my_dict.get(key) == 3 or 4 or 5: - print(f'{my_dict.get(key)}, время года года - весна') - elif my_dict.get(key) == 6 or 7 or 8: - print(f'{my_dict.get(key)}, время года года - лето') - elif my_dict.get(key) == 9 or 10 or 11: - print(f'{my_dict.get(key)}, время года года - осень') - else: - print('Некорректный ввод') - """ - Решение с помощью списка - """ - elif do == '2': - four_seasons = ['Зима', 'Весна', 'Лето', 'Осень'] - key = int(input('Введите номер месяца: ')) - try: - print(four_seasons[key // 3]) - except IndexError: - print('Зима') - - -def num4(): - string = input('Введите строку: ') - my_list = string.split(' ') - for i in my_list: - print(f'{my_list.index(i) + 1}) {i[0:10]}') - - -def num5(): - my_list = [5, 5, 10, 4, 1, 4, 4, 6, 2, 6, 10, 7] - my_list.sort() - el = input('Введите элемент списка: ') - while el != '': - el = int(el) - try: - pos = my_list.index(el) - except ValueError: - my_list.append(el) - my_list.sort() - else: - my_list.insert(pos, el) - el = input('Введите элемент списка: ') - print(my_list) - my_list.reverse() - print(f'Рейтинговый список:\n{my_list}') - - -""" -"condition" - это функция для условия "if" в заданнии 6. -Она проходит по списку, элементами которого являются кортежи вида: (индекс, словарь), -запрашивает j-ый элемент списка, 1-ый элемент кортежа и переходит таким образом к работе со словарем. -Функцией "my_dict.setdefault(nom))" запрашивает значение, находящееся под ключ-переменной "nom" -и добавляет его в список значений "values". -Полученный список ("values") становится значением нового, локального, словаря "my_dict_local" -с ключом "nom". -В результате работы данной функции получаются словари следующего вида: -“название”: [“компьютер”, “принтер”, “сканер”], -“цена”: [20000, 6000, 2000], -“количество”: [5, 2, 7], -“ед”: [“шт.”] -""" - - -def condition(j, my_list, values, nom): - while j < len(my_list): - values.append(my_list[j][1].setdefault(nom)) - j += 1 - my_dict_local = {nom: values} - print(my_dict_local) - - -def num6(): - my_list = [] - i = 0 - do = '' - print('Выберите действие:') - while do != '3': - do = input('1.Добавить товар\t2.Выборка\t3.Выход\n') - if do == '1': - name = input('Наименование: ') - price = input('Цена: ') - quantity = input('Количество: ') - unit = input('Единица измерения: ') - my_dict = {'Наименование': name, 'Цена': price, 'Количество': quantity, 'ед.': unit} - my_tuple = (i + 1, my_dict) - i += 1 - my_list.append(my_tuple) - elif do == '2': - values = [] - j = 0 - do = input('1.Наименование\n2.Цена\n3.Количество\n4.ед.\n') - if do == '1': - condition(j, my_list, values, 'Наименование') - elif do == '2': - condition(j, my_list, values, 'Цена') - elif do == '3': - condition(j, my_list, values, 'Количество.') - elif do == '4': - condition(j, my_list, values, 'ед.') - - -""" -main(): -""" -q = ' ' -while q != '': - q = input('Введите номер задания или нажмите ENTER: ') - if q == '1': - num1() - elif q == '2': - num2() - elif q == '3': - num3() - elif q == '4': - num4() - elif q == '5': - num5() - elif q == '6': - num6() From 67cbd83ae61da4a9a63fd90bd17a4264fd187817 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:19:24 +0300 Subject: [PATCH 30/92] Delete misc.xml --- lesson2/.idea/misc.xml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lesson2/.idea/misc.xml diff --git a/lesson2/.idea/misc.xml b/lesson2/.idea/misc.xml deleted file mode 100644 index d56657a..0000000 --- a/lesson2/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 66e67aaf97458c353244f76499fde5f97e3b7b71 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:19:36 +0300 Subject: [PATCH 31/92] Delete homework3.py --- lesson3/homework3.py | 170 ------------------------------------------- 1 file changed, 170 deletions(-) delete mode 100644 lesson3/homework3.py diff --git a/lesson3/homework3.py b/lesson3/homework3.py deleted file mode 100644 index 199520e..0000000 --- a/lesson3/homework3.py +++ /dev/null @@ -1,170 +0,0 @@ -""" -Выполнил: Агеев Георгий (BigData 1795) -""" -""" -Индекс в названии функции соответствует номеру задания -""" -""" -Для демонстрации работы функций следуйте инструкции после запуска программы -""" -""" -ВНИМАНИЕ! -Для 6-го задания предусмотрены варианты ввода: 6.1 - для обратоки слова, 6.2 - для обработки нескольких слов -""" - - -def num1(a, b): - try: - print(a/b) - except ZeroDivisionError: - print('Деление на 0') - print('Попробуте еще раз!') - a = int(input('Числитель = ')) - b = int(input('Знаменатель = ')) - print(a / b) - return a/b - - -def num2(name, nom, born, city, email, number): - print(f'Имя: {name}\tФамилия: {nom}\tГод рождения: {born}\tГород: {city}\te-mail: {email}\tТелефон: {number}\n') - - -def num3(a, b, c, j): - my_list = [a, b, c] - """ - Определяю тип переменной: int или float - """ - for i in my_list: - if i.isdigit() is True: - i = int(i) - else: - check = i.split('.') - if len(check) == 2: - if check[0].isdigit() and check[1].isdigit(): - i = float(i) - my_list[j] = i - j += 1 - """ - Цикл на случай, если решение требует не использовать функцию ".sort()" - """ - """ - j = 0 - while j < 2: - if my_list[j] > my_list[j + 1]: - my_list[j + 1] = my_list[j] - else: - j += 1 - j += 1 - """ - my_list.sort() - print(my_list[1] + my_list[2]) - return my_list[1] + my_list[2] - - -def num4(x, y): - for i in range(abs(y)): - x *= x - print(1 / x) - return 1 / x - - -def num5(string, sum, j): - """ - Суммирование вводимых чисел до того, как попадется специальный символ "q" - """ - while string.count('q') == 0: - my_list = string.split(' ') - for i in my_list: - sum += int(i) - print(sum) - string = input('Введите числа через пробел: ') - string.count('q') - """ - Как только строка содержит специальный символ, происходит суммирование чисел перед ним - работа завершается - """ - my_list = string.split(' ') - while my_list[j] != 'q': - sum += int(my_list[j]) - j += 1 - print(sum) - - -""" -Вспомогательная функция к заданию "6", обрататывающая, по заданию, одно слово -""" - - -def helper(my_string, i): - alphabet = (('a', 'A'), ('b', 'B'), ('c', 'C'), ('d', 'D'), ('e', 'E'), - ('f', 'F'), ('g', 'G'), ('h', 'H'), ('i', 'I'), ('j', 'J'), - ('k', 'K'), ('l', 'L'), ('m', 'M'), ('n', 'N'), ('o', 'O'), - ('p', 'P'), ('q', 'Q'), ('r', 'R'), ('s', 'S'), ('t', 'T'), - ('u', 'U'), ('v', 'V'), ('w', 'W'), ('x', 'X'), ('y', 'Y'), ('z', 'Z')) - while my_string[0] != alphabet[i][0]: - i += 1 - print(alphabet[i][1] + my_string[1:]) - return alphabet[i][1] + my_string[1:] - - -""" -Здание 6.2. Например, вы ввели: aleksandra shapovalova - Результат: Aleksandra - Shapovalova - Aleksandra Shapovalova - Первые две строки отображаются в результате работы функции "helper" -""" - - -def num6(string): - """ - Список, чтобы собрать функцкцией .join() - """ - my_list = [] - """ - Работа функции "helper" над каждым словом строки, введенной пользователем - """ - for j in string.split(' '): - my_list.append(helper(j, 0)) - """ - Сброка получившегося списка в строку - """ - print(' '.join(my_list)) - return ' '.join(my_list) - - -""" -main(): -""" -q = ' ' -while q != '': - q = input('Введите номер задания или нажмите ENTER: ') - if q == '1': - a = int(input('Числитель = ')) - b = int(input('Знаменатель = ')) - num1(a, b) - elif q == '2': - name = input('Имя: ') - nom = input('Фамилия: ') - born = input('Год рождения: ') - city = input('Город: ') - email = input('e-mail: ') - number = input('Телефон: ') - num2(name, nom, born, city, email, number) - elif q == '3': - a = input('a = ') - b = input('b = ') - c = input('c = ') - num3(a, b, c, 0) - elif q == '4': - x = abs(float(input('Введите действительное положительное число: '))) - y = int(input('Введите целое отрицательное число: ')) - num4(x, y) - elif q == '5': - string = input('Введите числа через пробел: ') - num5(string, 0, 0) - elif q == '6.1': - my_string = input('Введите слово из маленьких латинских букв: ') - helper(my_string, 0) - elif q == '6.2': - string = input('Введите слова из маленьких латинских букв: ') - num6(string) From c287bdc799c60a6ba7c551e6d138daf3a4123409 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:19:46 +0300 Subject: [PATCH 32/92] Delete modules.xml --- lesson3/.idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson3/.idea/modules.xml diff --git a/lesson3/.idea/modules.xml b/lesson3/.idea/modules.xml deleted file mode 100644 index 964f100..0000000 --- a/lesson3/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 33d034c8f1ea3f6cda30cc6f4a3ecf8be8a519c5 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:19:55 +0300 Subject: [PATCH 33/92] Delete workspace.xml --- lesson4/.idea/workspace.xml | 49 ------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 lesson4/.idea/workspace.xml diff --git a/lesson4/.idea/workspace.xml b/lesson4/.idea/workspace.xml deleted file mode 100644 index 05e0a1e..0000000 --- a/lesson4/.idea/workspace.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1634843454449 - - - - \ No newline at end of file From a7d8772eba0a6335bf43f22036b0d9a6a9496fc4 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:20:02 +0300 Subject: [PATCH 34/92] Delete vcs.xml --- lesson4/.idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lesson4/.idea/vcs.xml diff --git a/lesson4/.idea/vcs.xml b/lesson4/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/lesson4/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 49ca3a84e6e1eba33463c51e3c7ea4c877a57650 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:20:09 +0300 Subject: [PATCH 35/92] Delete modules.xml --- lesson4/.idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson4/.idea/modules.xml diff --git a/lesson4/.idea/modules.xml b/lesson4/.idea/modules.xml deleted file mode 100644 index 964f100..0000000 --- a/lesson4/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 9f50eb7c73e2743c9b5e28e6de0c75931d207d42 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:20:19 +0300 Subject: [PATCH 36/92] Delete homework4.py --- lesson4/homework4.py | 124 ------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 lesson4/homework4.py diff --git a/lesson4/homework4.py b/lesson4/homework4.py deleted file mode 100644 index d599f29..0000000 --- a/lesson4/homework4.py +++ /dev/null @@ -1,124 +0,0 @@ -from functools import reduce -from itertools import count, cycle -from sys import argv -from random import randrange - - -""" -Выполнил: Агеев Георгий BigData 1795 -""" -""" -Индекс в названии функции соответствует номеру задания -""" -""" -Для демонстрации работы функций следуйте инструкции после запуска программы -""" -""" -Для 6-го задания предусмотрены варианты ввода: 6.1, 6.2 -""" - - -""" -Номер 1 -""" -name, hours, money_in_hour, prize = argv -salary = int(money_in_hour) * int(hours) + int(prize) -print(salary) - - -def num2(i=0): - new_list = [] - len_list = randrange(20) - my_gen = [randrange(20) for i in range(len_list)] - print(my_gen) - try: - while i != (len_list - 1): - if my_gen[i] < my_gen[i + 1]: - new_list.append(my_gen[i + 1]) - i += 1 - except IndexError: - print(new_list) - else: - print(new_list) - - -def num3(): - gen = (i for i in range(20, 241) if i % 20 == 0 or i % 21 == 0) - return gen - - -def num4(): - len_gen = randrange(20) - gen = [randrange(20) for i in range(len_gen)] - print(gen) - new_gen = [el for el in gen if gen.count(el) == 1] - return new_gen - - -def num5(): - gen = [i for i in range(100, 1001) if i%2 == 0] - print(gen) - return reduce(lambda a, b: a * b, gen) - - -def num6_1(a, b, c): - for i in count(a, b): - if i >= c: - break - yield i - - -def num6_2(my_list, steps, counter=0): - for i in cycle(my_list): - """ - steps*len(my_list) - число шагов в одном обороте "cycle()" - """ - if counter >= steps*len(my_list): - break - yield i - counter += 1 - - -def num7(n, a=1): - for i in range(1, n+1): - a *= i - yield a - - -""" -main(): -""" -q = ' ' -while q != '': - q = input('Введите номер задания или нажмите ENTER: ') - if q == '1': - print(f'Заработная плата: {salary}') - elif q == '2': - num2() - elif q == '3': - for el in num3(): - print(el) - elif q == '4': - print(num4()) - elif q == '5': - print(num5()) - elif q == '6.1': - a = int(input('Стартовое число: ')) - b = int(input('Шаг: ')) - c = int(input('Предел: ')) - for el in num6_1(a, b, c): - print(el) - elif q == '6.2': - my_list = [] - el = input('Введите элемент списка или ENTER: ') - while el != '': - my_list.append(el) - el = input('Введите элемент списка или ENTER: ') - print('Оборот - полное прохождение "cycle()" по аргументу-списку') - steps = int(input('Введите число оборотов "cycle()": ')) - for el in num6_2(my_list, steps, 0): - print(el) - elif q == '7': - n = int(input('Найти фаториал числа: ')) - for el in num7(n): - print(el) From 564802cd784902102f7faf008f2e1f05576098ea Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:20:27 +0300 Subject: [PATCH 37/92] Delete misc.xml --- lesson4/.idea/misc.xml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lesson4/.idea/misc.xml diff --git a/lesson4/.idea/misc.xml b/lesson4/.idea/misc.xml deleted file mode 100644 index 2c92b24..0000000 --- a/lesson4/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 2fc08a8b299bb36827ea46135be19c4a139b4604 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:00 +0300 Subject: [PATCH 38/92] Delete .gitignore --- lesson2/.idea/.gitignore | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 lesson2/.idea/.gitignore diff --git a/lesson2/.idea/.gitignore b/lesson2/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/lesson2/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml From 6baccb5a4cbc28faf083bc6ccc76e3d49057c2f8 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:08 +0300 Subject: [PATCH 39/92] Delete homework2.iml --- lesson2/.idea/homework2.iml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson2/.idea/homework2.iml diff --git a/lesson2/.idea/homework2.iml b/lesson2/.idea/homework2.iml deleted file mode 100644 index d0876a7..0000000 --- a/lesson2/.idea/homework2.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 32704a8e1d4fa8ea381dde0572c0e3b7ca06328b Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:16 +0300 Subject: [PATCH 40/92] Delete .gitignore --- lesson3/.idea/.gitignore | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 lesson3/.idea/.gitignore diff --git a/lesson3/.idea/.gitignore b/lesson3/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/lesson3/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml From 9c60ad531b9ffa684641bd05c9c942cb223edfd6 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:25 +0300 Subject: [PATCH 41/92] Delete BigData.iml --- lesson3/.idea/BigData.iml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lesson3/.idea/BigData.iml diff --git a/lesson3/.idea/BigData.iml b/lesson3/.idea/BigData.iml deleted file mode 100644 index d0876a7..0000000 --- a/lesson3/.idea/BigData.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 0934a6ea66cff249b7dffc73551930f01e8e60ad Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:31 +0300 Subject: [PATCH 42/92] Delete profiles_settings.xml --- lesson3/.idea/inspectionProfiles/profiles_settings.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lesson3/.idea/inspectionProfiles/profiles_settings.xml diff --git a/lesson3/.idea/inspectionProfiles/profiles_settings.xml b/lesson3/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/lesson3/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file From 4bdedb2cf6fddf45f3c426df6080641c2c5c9212 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:37 +0300 Subject: [PATCH 43/92] Delete BigData.iml --- lesson4/.idea/BigData.iml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 lesson4/.idea/BigData.iml diff --git a/lesson4/.idea/BigData.iml b/lesson4/.idea/BigData.iml deleted file mode 100644 index f06d9bd..0000000 --- a/lesson4/.idea/BigData.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file From 02fb2f50adcd0182e90a347ed3745d9142da2af0 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:21:47 +0300 Subject: [PATCH 44/92] Delete profiles_settings.xml --- lesson4/.idea/inspectionProfiles/profiles_settings.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lesson4/.idea/inspectionProfiles/profiles_settings.xml diff --git a/lesson4/.idea/inspectionProfiles/profiles_settings.xml b/lesson4/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/lesson4/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file From a4bdd7326c23777d3c6a33dfd89332ccfab5264d Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:22:10 +0300 Subject: [PATCH 45/92] Delete misc.xml --- lesson3/.idea/misc.xml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lesson3/.idea/misc.xml diff --git a/lesson3/.idea/misc.xml b/lesson3/.idea/misc.xml deleted file mode 100644 index d56657a..0000000 --- a/lesson3/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From e3d57df89d125d1a83d06b737cfb206980ead917 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:22:26 +0300 Subject: [PATCH 46/92] Delete homework4.py --- homework4.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 homework4.py diff --git a/homework4.py b/homework4.py deleted file mode 100644 index e69de29..0000000 From e87533f0a0326cc9ef8b14353ac059a13f9f83a8 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 28 Oct 2021 19:22:32 +0300 Subject: [PATCH 47/92] Delete .gitignore --- lesson1/.idea/.gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lesson1/.idea/.gitignore diff --git a/lesson1/.idea/.gitignore b/lesson1/.idea/.gitignore deleted file mode 100644 index e69de29..0000000 From a018495af4a79529f198d8736955a420eb221f08 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 29 Oct 2021 10:16:41 +0300 Subject: [PATCH 48/92] update --- lesson5/homework5.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 6185143..257db6c 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -14,7 +14,7 @@ def num1(): def num2(lines=0, words=0): - fout = open('ex2.txt', 'r', encoding='UTF-8') + fout = open('ex2.txt', encoding='UTF-8') for i in fout.readlines(): print(f"Число слов в строке {lines + 1}: {len(i.split())}") lines += 1 @@ -23,7 +23,7 @@ def num2(lines=0, words=0): def num3(i=0, count=0): - with open('ex3.txt', 'r', encoding='UTF-8') as fout: + with open('ex3.txt', encoding='UTF-8') as fout: for line in fout: surname, salary = line.split() i += int(salary) @@ -35,22 +35,25 @@ def num3(i=0, count=0): def num4(i=0): - fout = open('ex4.txt', 'r', encoding='UTF-8') + fout = open('ex4.txt', encoding='UTF-8') fin = open('ex4_in.txt', 'w', encoding='UTF-8') my_list = ['Один', 'Два', 'Три', 'Четыре'] for line in fout: line = line.split(' - ') line[0] = my_list[i] - new_line = ' - '.join(line) - fin.write(new_line) + fin.write(' - '.join(line)) i += 1 fout.close() fin.close() def num5(i=0, sum=0): - with open('ex5.txt', 'r+', encoding='UTF - 8') as fin: - print('5 0 1 2 3 7 9 5 6 81 4 56 1', file=fin) + with open('ex5.txt', 'w+', encoding='UTF - 8') as fin: + fin.write('5 0 1 2 3 7 9 5 6 81 4 56 1') + fin.seek(0) for i in fin.readline().split(): sum += int(i) print(sum) + + + From b7bc23c6517538691b0278da47920e7c49c34601 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 29 Oct 2021 10:19:50 +0300 Subject: [PATCH 49/92] news --- lesson5/ex5.txt | 1 + lesson5/ex6.txt | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 lesson5/ex5.txt create mode 100644 lesson5/ex6.txt diff --git a/lesson5/ex5.txt b/lesson5/ex5.txt new file mode 100644 index 0000000..1d72e45 --- /dev/null +++ b/lesson5/ex5.txt @@ -0,0 +1 @@ +5 0 1 2 3 7 9 5 6 81 4 56 1 \ No newline at end of file diff --git a/lesson5/ex6.txt b/lesson5/ex6.txt new file mode 100644 index 0000000..f175367 --- /dev/null +++ b/lesson5/ex6.txt @@ -0,0 +1,10 @@ +Матанализ: 16(л) 8(пр) +Физика: 16(л) 8(пр) 5(лаб) +Теория инофрмации: 8(л) 8(пр) 2(лаб) +Английский: 24(пр) +Тервер: 16(л) 16(пр) +Дифуры: 16(л) 16(пр) +Дискретка: 16(л) 16(пр) +ОПД: 8(пр) 1(лаб) +Физра: 8(лаб) +ТФКП: 16(лек) \ No newline at end of file From 88767b1696fe99219271bd5eb4d4ae4bcbefc6f7 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 10:25:20 +0300 Subject: [PATCH 50/92] Update homework5.py --- lesson5/homework5.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 6185143..c673918 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -2,7 +2,7 @@ Агеев Георгий BigData 1795 """ """ -Добавлю две задачи и опишу 5-ую +Добавлю две задачи """ def num1(): fin = open('ex1.txt', 'w', encoding='UTF-8') @@ -14,7 +14,7 @@ def num1(): def num2(lines=0, words=0): - fout = open('ex2.txt', 'r', encoding='UTF-8') + fout = open('ex2.txt', encoding='UTF-8') for i in fout.readlines(): print(f"Число слов в строке {lines + 1}: {len(i.split())}") lines += 1 @@ -23,7 +23,7 @@ def num2(lines=0, words=0): def num3(i=0, count=0): - with open('ex3.txt', 'r', encoding='UTF-8') as fout: + with open('ex3.txt', encoding='UTF-8') as fout: for line in fout: surname, salary = line.split() i += int(salary) @@ -35,22 +35,22 @@ def num3(i=0, count=0): def num4(i=0): - fout = open('ex4.txt', 'r', encoding='UTF-8') + fout = open('ex4.txt', encoding='UTF-8') fin = open('ex4_in.txt', 'w', encoding='UTF-8') my_list = ['Один', 'Два', 'Три', 'Четыре'] for line in fout: line = line.split(' - ') line[0] = my_list[i] - new_line = ' - '.join(line) - fin.write(new_line) + fin.write(' - '.join(line)) i += 1 fout.close() fin.close() def num5(i=0, sum=0): - with open('ex5.txt', 'r+', encoding='UTF - 8') as fin: - print('5 0 1 2 3 7 9 5 6 81 4 56 1', file=fin) + with open('ex5.txt', 'w+', encoding='UTF - 8') as fin: + fin.write('5 0 1 2 3 7 9 5 6 81 4 56 1') + fin.seek(0) for i in fin.readline().split(): sum += int(i) print(sum) From 2f14c9ae1590e8d782d6d49968efa39cc9e3f7f3 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 12:04:21 +0300 Subject: [PATCH 51/92] Update homework5.py --- lesson5/homework5.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index c673918..f03bfd1 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -54,3 +54,19 @@ def num5(i=0, sum=0): for i in fin.readline().split(): sum += int(i) print(sum) + + +def num6(result_dict={}): + with open('ex6.txt', encoding='UTF - 8') as fout: + for line in fout: + line = line.split() + sum = 0 + for i in line: + try: + i = i.split('(') + sum += int(i[0]) + except ValueError: + pass + unit_dict = {line[0][:-1]: {sum}} + result_dict.update(unit_dict) + print(result_dict) From db9c8eef2afb72115ff60eecafd212f4cc432fdc Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 12:04:43 +0300 Subject: [PATCH 52/92] Update homework5.py --- lesson5/homework5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index f03bfd1..c0e607e 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -2,7 +2,7 @@ Агеев Георгий BigData 1795 """ """ -Добавлю две задачи +Добавлю 7-ую """ def num1(): fin = open('ex1.txt', 'w', encoding='UTF-8') From 730c11ee8f2264c31b243eb4ea783edc8773e115 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 12:05:15 +0300 Subject: [PATCH 53/92] Update homework5.py --- lesson5/homework5.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index c0e607e..9a7ae24 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -70,3 +70,23 @@ def num6(result_dict={}): unit_dict = {line[0][:-1]: {sum}} result_dict.update(unit_dict) print(result_dict) + + + """ +main(): +""" +q = ' ' +while q != '': + q = input('Введите номер задания или нажмите ENTER: ') + if q == '1': + num1() + elif q == '2': + num2() + elif q == '3': + num3() + elif q == '4': + num4() + elif q == '5': + num5() + elif q == '6': + num6() From 741acd99ca7b00dd4c8c33a30eede7a6a74e6f5c Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 12:06:12 +0300 Subject: [PATCH 54/92] Update homework5.py --- lesson5/homework5.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 9a7ae24..3befb01 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -33,7 +33,6 @@ def num3(i=0, count=0): print(f'Средняя величина дохода: {int(i/count)}') - def num4(i=0): fout = open('ex4.txt', encoding='UTF-8') fin = open('ex4_in.txt', 'w', encoding='UTF-8') @@ -72,7 +71,7 @@ def num6(result_dict={}): print(result_dict) - """ +""" main(): """ q = ' ' From 0ab02328fb3ab0c4ea7b84b271ee0cba4e9320b8 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:11:14 +0300 Subject: [PATCH 55/92] Update homework5.py --- lesson5/homework5.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 3befb01..725fe3b 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -71,6 +71,27 @@ def num6(result_dict={}): print(result_dict) +def num7(all_profit=0, count=0, firm_dict={}): + with open('ex7.txt', encoding='UTF - 8') as fout: + for line in fout: + line = line.split() + profit = int(line[2]) - int(line[3]) + if profit > 0: + all_profit += profit + else: + pass + count += 1 + unit_dict = {line[0]: profit} + firm_dict.update(unit_dict) + my_list = [firm_dict, {'Average profit': all_profit / count}] + print(my_list) + """ + json + """ + with open('ex7.json','w' ,encoding='UTF - 8') as fin: + fin.write(json.dumps(my_list)) + + """ main(): """ @@ -89,3 +110,5 @@ def num6(result_dict={}): num5() elif q == '6': num6() + elif q == '7': + num7() From 11e26893b6ba3798a0f45aaccf08c916e3f4c50d Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:11:33 +0300 Subject: [PATCH 56/92] Update homework5.py From 8f820c41b9a986b24daf213507c0066add3f9fbf Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:21:21 +0300 Subject: [PATCH 57/92] Update homework5.py --- lesson5/homework5.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 725fe3b..65a0d33 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -54,7 +54,14 @@ def num5(i=0, sum=0): sum += int(i) print(sum) - + +""" +Успел сделать топорный вариант в рамках заполнения файла, как в примере. +В адекватном решении использовал бы read() + seek() + для чтения файловой строки поэлементно. +Если за попавшимся int тоже следует int, + то конкотенирую строковые числа и если далее следует не цифра, то делаю их интом int(str+str) +""" def num6(result_dict={}): with open('ex6.txt', encoding='UTF - 8') as fout: for line in fout: From 0527bfc8911586db8e350640e9f3c41e7f41189b Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:21:49 +0300 Subject: [PATCH 58/92] Update homework5.py --- lesson5/homework5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 65a0d33..23f9dee 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -56,7 +56,7 @@ def num5(i=0, sum=0): """ -Успел сделать топорный вариант в рамках заполнения файла, как в примере. +Успел сделать только топорный вариант в рамках заполнения файла, как в примере. В адекватном решении использовал бы read() + seek() для чтения файловой строки поэлементно. Если за попавшимся int тоже следует int, From 4bbfe1732aec3aebfde7d36c3b844d524e405514 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:22:23 +0300 Subject: [PATCH 59/92] Update homework5.py --- lesson5/homework5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 23f9dee..0dc9782 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -60,7 +60,7 @@ def num5(i=0, sum=0): В адекватном решении использовал бы read() + seek() для чтения файловой строки поэлементно. Если за попавшимся int тоже следует int, - то конкотенирую строковые числа и если далее следует не цифра, то делаю их интом int(str+str) + то конкотенирую строковые числа и, если далее следует не цифра, то делаю их интом int(str+str) """ def num6(result_dict={}): with open('ex6.txt', encoding='UTF - 8') as fout: From 9aad30be9e1d05551797eeac93d394e292ffa240 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:23:07 +0300 Subject: [PATCH 60/92] Update homework5.py --- lesson5/homework5.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 0dc9782..82a894b 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -1,9 +1,10 @@ """ Агеев Георгий BigData 1795 """ -""" -Добавлю 7-ую -""" + +import json + + def num1(): fin = open('ex1.txt', 'w', encoding='UTF-8') data = input('Введите данные для записи в файл или пустую строку: ') From e23194916ff316446f151284333014749fc390b4 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 14:04:49 +0300 Subject: [PATCH 61/92] Update homework5.py --- lesson5/homework5.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 82a894b..1bf39aa 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -1,7 +1,9 @@ """ Агеев Георгий BigData 1795 """ - +""" +Добавлю две задачи и опишу 5-ую +""" import json @@ -31,7 +33,7 @@ def num3(i=0, count=0): if int(salary) < 20000: print(surname) count += 1 - print(f'Средняя величина дохода: {int(i/count)}') + print(f'Средняя величина дохода: {int(i / count)}') def num4(i=0): @@ -57,28 +59,42 @@ def num5(i=0, sum=0): """ -Успел сделать только топорный вариант в рамках заполнения файла, как в примере. +Успел сделать топорный вариант в рамках заполнения файла, как в примере. В адекватном решении использовал бы read() + seek() для чтения файловой строки поэлементно. Если за попавшимся int тоже следует int, - то конкотенирую строковые числа и, если далее следует не цифра, то делаю их интом int(str+str) + то конкотенирую строковые числа и если далее следует не цифра, то делаю их интом int(str+str) """ + + def num6(result_dict={}): with open('ex6.txt', encoding='UTF - 8') as fout: for line in fout: line = line.split() sum = 0 + """ + Разбил строку на слова без пробелов + """ for i in line: + """ + Каждое слово делю на две части по "(" + Для названия предмета, которое всегда стоит первым элементом в списке, + а так же для случаев, когда стоит прочерк, описываю try - except: + """ try: i = i.split('(') sum += int(i[0]) except ValueError: pass + """ + line[0] - первый элемент каждой строки в файле - название предмета + После названия предмета следует ":", поэтому делаю срез строки + """ unit_dict = {line[0][:-1]: {sum}} result_dict.update(unit_dict) print(result_dict) - + def num7(all_profit=0, count=0, firm_dict={}): with open('ex7.txt', encoding='UTF - 8') as fout: for line in fout: @@ -96,10 +112,10 @@ def num7(all_profit=0, count=0, firm_dict={}): """ json """ - with open('ex7.json','w' ,encoding='UTF - 8') as fin: + with open('ex7.json', 'w', encoding='UTF - 8') as fin: fin.write(json.dumps(my_list)) - - + + """ main(): """ From 04697f19ca05733ddfe9ecfe28b2c5c31433f166 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 29 Oct 2021 14:06:22 +0300 Subject: [PATCH 62/92] new file --- lesson5/ex6.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lesson5/ex6.txt b/lesson5/ex6.txt index f175367..08ed51e 100644 --- a/lesson5/ex6.txt +++ b/lesson5/ex6.txt @@ -1,10 +1,10 @@ -Матанализ: 16(л) 8(пр) +Матанализ: 16(л) 8(пр) - Физика: 16(л) 8(пр) 5(лаб) -Теория инофрмации: 8(л) 8(пр) 2(лаб) -Английский: 24(пр) -Тервер: 16(л) 16(пр) -Дифуры: 16(л) 16(пр) -Дискретка: 16(л) 16(пр) -ОПД: 8(пр) 1(лаб) -Физра: 8(лаб) -ТФКП: 16(лек) \ No newline at end of file +Теринф: 8(л) 8(пр) 2(лаб) +Английский: - 24(пр) - +Тервер: 16(л) 16(пр) - +Дифуры: 16(л) 16(пр) - +Дискретка: 16(л) 16(пр) - +ОПД: - 8(пр) 1(лаб) +Физра: - - 8(лаб) +ТФКП: 16(лек) - - \ No newline at end of file From 3cc5b3e6f88912e81f75aa14f05fef3f71c72e1c Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 14:08:44 +0300 Subject: [PATCH 63/92] Update homework5.py --- lesson5/homework5.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 1bf39aa..ab2d0b5 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -1,9 +1,8 @@ """ Агеев Георгий BigData 1795 """ -""" -Добавлю две задачи и опишу 5-ую -""" + + import json From 3adc0218a9cd7f8a7c5930cff50b5d51069d37bb Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Fri, 29 Oct 2021 14:11:52 +0300 Subject: [PATCH 64/92] Update homework5.py --- lesson5/homework5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index ab2d0b5..d9ada8f 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -67,7 +67,7 @@ def num5(i=0, sum=0): def num6(result_dict={}): - with open('ex6.txt', encoding='UTF - 8') as fout: + with open('ex6.txt', encoding='UTF-8') as fout: for line in fout: line = line.split() sum = 0 From 3863a50d4d59732bf45110df5cb24e38890fd4d5 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 29 Oct 2021 14:16:32 +0300 Subject: [PATCH 65/92] update --- lesson5/homework5.py | 88 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 5 deletions(-) diff --git a/lesson5/homework5.py b/lesson5/homework5.py index 257db6c..ab2d0b5 100644 --- a/lesson5/homework5.py +++ b/lesson5/homework5.py @@ -1,9 +1,11 @@ """ Агеев Георгий BigData 1795 """ -""" -Добавлю две задачи и опишу 5-ую -""" + + +import json + + def num1(): fin = open('ex1.txt', 'w', encoding='UTF-8') data = input('Введите данные для записи в файл или пустую строку: ') @@ -30,8 +32,7 @@ def num3(i=0, count=0): if int(salary) < 20000: print(surname) count += 1 - print(f'Средняя величина дохода: {int(i/count)}') - + print(f'Средняя величина дохода: {int(i / count)}') def num4(i=0): @@ -56,4 +57,81 @@ def num5(i=0, sum=0): print(sum) +""" +Успел сделать топорный вариант в рамках заполнения файла, как в примере. +В адекватном решении использовал бы read() + seek() + для чтения файловой строки поэлементно. +Если за попавшимся int тоже следует int, + то конкотенирую строковые числа и если далее следует не цифра, то делаю их интом int(str+str) +""" + +def num6(result_dict={}): + with open('ex6.txt', encoding='UTF - 8') as fout: + for line in fout: + line = line.split() + sum = 0 + """ + Разбил строку на слова без пробелов + """ + for i in line: + """ + Каждое слово делю на две части по "(" + Для названия предмета, которое всегда стоит первым элементом в списке, + а так же для случаев, когда стоит прочерк, описываю try - except: + """ + try: + i = i.split('(') + sum += int(i[0]) + except ValueError: + pass + """ + line[0] - первый элемент каждой строки в файле - название предмета + После названия предмета следует ":", поэтому делаю срез строки + """ + unit_dict = {line[0][:-1]: {sum}} + result_dict.update(unit_dict) + print(result_dict) + + +def num7(all_profit=0, count=0, firm_dict={}): + with open('ex7.txt', encoding='UTF - 8') as fout: + for line in fout: + line = line.split() + profit = int(line[2]) - int(line[3]) + if profit > 0: + all_profit += profit + else: + pass + count += 1 + unit_dict = {line[0]: profit} + firm_dict.update(unit_dict) + my_list = [firm_dict, {'Average profit': all_profit / count}] + print(my_list) + """ + json + """ + with open('ex7.json', 'w', encoding='UTF - 8') as fin: + fin.write(json.dumps(my_list)) + + +""" +main(): +""" +q = ' ' +while q != '': + q = input('Введите номер задания или нажмите ENTER: ') + if q == '1': + num1() + elif q == '2': + num2() + elif q == '3': + num3() + elif q == '4': + num4() + elif q == '5': + num5() + elif q == '6': + num6() + elif q == '7': + num7() From e014743addac2831c7364845a0d9b0ccffb21448 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 29 Oct 2021 14:18:33 +0300 Subject: [PATCH 66/92] what if --- .idea/workspace.xml | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8aa7cb3..78b6aa5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,19 +2,22 @@ - - - - - - - + + + + + + @@ -26,9 +29,9 @@ - + - + + + + + From 38b0c40876fb2be6c101ed6a914aa140dda4fdce Mon Sep 17 00:00:00 2001 From: Elvirience Date: Mon, 1 Nov 2021 18:26:59 +0300 Subject: [PATCH 67/92] give me time --- lesson6/homework6.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lesson6/homework6.py diff --git a/lesson6/homework6.py b/lesson6/homework6.py new file mode 100644 index 0000000..80e637d --- /dev/null +++ b/lesson6/homework6.py @@ -0,0 +1,6 @@ +from itertools import cycle +import time + + +class TrafficLight: + From d1291e9c2a0862fa68797c5522d1a23af87c9aea Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:28:34 +0300 Subject: [PATCH 68/92] Delete workspace.xml --- .idea/workspace.xml | 107 -------------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 78b6aa5..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1634885950324 - - - - - - - \ No newline at end of file From 5db2a50c918c8897f8ce57f35dab0eee4fa43f17 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:28:43 +0300 Subject: [PATCH 69/92] Delete ex2.txt --- lesson5/ex2.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 lesson5/ex2.txt diff --git a/lesson5/ex2.txt b/lesson5/ex2.txt deleted file mode 100644 index 46a4915..0000000 --- a/lesson5/ex2.txt +++ /dev/null @@ -1,3 +0,0 @@ -do did done -1 2 3 -Привет \ No newline at end of file From 329e2fe9059274acb51f6159d1a4235b7ce988f2 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:28:50 +0300 Subject: [PATCH 70/92] Delete ex3.txt --- lesson5/ex3.txt | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 lesson5/ex3.txt diff --git a/lesson5/ex3.txt b/lesson5/ex3.txt deleted file mode 100644 index 6e04d5f..0000000 --- a/lesson5/ex3.txt +++ /dev/null @@ -1,17 +0,0 @@ -Несветова 150000 -Адамов 98687 -Денисов 231185 -Рюрикович 127080 -Робертс 1000000 -Монтана 398400 -Тодд 580900 -О'Клай 497568 -Королев 352698 -Руккулус 19500 -Катрин 18668 -Агеев 3140329 -Басов 2000288 -Макушин 1400356 -Годес 190543 -Бирюков 32999 -Пискарев 400650 \ No newline at end of file From 9319ecf787c17598dbf7a2e4a4c0956f68641c58 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:28:55 +0300 Subject: [PATCH 71/92] Delete ex4.txt --- lesson5/ex4.txt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lesson5/ex4.txt diff --git a/lesson5/ex4.txt b/lesson5/ex4.txt deleted file mode 100644 index 48de98b..0000000 --- a/lesson5/ex4.txt +++ /dev/null @@ -1,4 +0,0 @@ -One - 1 -Two - 2 -Three - 3 -Four - 4 \ No newline at end of file From 26f1b621499145a6978f2511c9fdeb09a2f5df15 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:29:01 +0300 Subject: [PATCH 72/92] Delete ex6.txt --- lesson5/ex6.txt | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 lesson5/ex6.txt diff --git a/lesson5/ex6.txt b/lesson5/ex6.txt deleted file mode 100644 index 08ed51e..0000000 --- a/lesson5/ex6.txt +++ /dev/null @@ -1,10 +0,0 @@ -Матанализ: 16(л) 8(пр) - -Физика: 16(л) 8(пр) 5(лаб) -Теринф: 8(л) 8(пр) 2(лаб) -Английский: - 24(пр) - -Тервер: 16(л) 16(пр) - -Дифуры: 16(л) 16(пр) - -Дискретка: 16(л) 16(пр) - -ОПД: - 8(пр) 1(лаб) -Физра: - - 8(лаб) -ТФКП: 16(лек) - - \ No newline at end of file From 3507c87f136cbfba65224fbde55f912824467ad3 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:29:08 +0300 Subject: [PATCH 73/92] Delete ex7.txt --- lesson5/ex7.txt | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 lesson5/ex7.txt diff --git a/lesson5/ex7.txt b/lesson5/ex7.txt deleted file mode 100644 index eb0e19b..0000000 --- a/lesson5/ex7.txt +++ /dev/null @@ -1,7 +0,0 @@ -MosAuto OOO 7545745 3344667 -SeriousBank OAO 4356043809 5495405 -GeneralStatistics OOO 7547547 434244 -WildestNanos OAO 5435954 454598 -NoNamers ZAO 4507497975 0 -Moshpitttt OAO 94594 394293 -Elvirience OAO 3464943080 48545008 \ No newline at end of file From c1604e5adcc8702b4a9922643b726ec39aba3156 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:29:18 +0300 Subject: [PATCH 74/92] Delete homework5.py --- lesson5/homework5.py | 141 ------------------------------------------- 1 file changed, 141 deletions(-) delete mode 100644 lesson5/homework5.py diff --git a/lesson5/homework5.py b/lesson5/homework5.py deleted file mode 100644 index e3e40d6..0000000 --- a/lesson5/homework5.py +++ /dev/null @@ -1,141 +0,0 @@ -""" -Агеев Георгий BigData 1795 -""" - - -import json - - -def num1(): - fin = open('ex1.txt', 'w', encoding='UTF-8') - data = input('Введите данные для записи в файл или пустую строку: ') - while data != '': - fin.write(data + '\n') - data = input('Введите данные для записи в файл или пустую строку: ') - fin.close() - - -def num2(lines=0, words=0): - fout = open('ex2.txt', encoding='UTF-8') - for i in fout.readlines(): - print(f"Число слов в строке {lines + 1}: {len(i.split())}") - lines += 1 - print(f'Число строк: {lines}') - fout.close() - - -def num3(i=0, count=0): - with open('ex3.txt', encoding='UTF-8') as fout: - for line in fout: - surname, salary = line.split() - i += int(salary) - if int(salary) < 20000: - print(surname) - count += 1 - print(f'Средняя величина дохода: {int(i / count)}') - - -def num4(i=0): - fout = open('ex4.txt', encoding='UTF-8') - fin = open('ex4_in.txt', 'w', encoding='UTF-8') - my_list = ['Один', 'Два', 'Три', 'Четыре'] - for line in fout: - line = line.split(' - ') - line[0] = my_list[i] - fin.write(' - '.join(line)) - i += 1 - fout.close() - fin.close() - - -def num5(i=0, sum=0): - with open('ex5.txt', 'w+', encoding='UTF - 8') as fin: - fin.write('5 0 1 2 3 7 9 5 6 81 4 56 1') - fin.seek(0) - for i in fin.readline().split(): - sum += int(i) - print(sum) - - -""" -Успел сделать топорный вариант в рамках заполнения файла, как в примере. -В адекватном решении использовал бы read() + seek() - для чтения файловой строки поэлементно. -Если за попавшимся int тоже следует int, - то конкотенирую строковые числа и если далее следует не цифра, то делаю их интом int(str+str) -""" - - -def num6(result_dict={}): -<<<<<<< HEAD - with open('ex6.txt', encoding='UTF - 8') as fout: -======= - with open('ex6.txt', encoding='UTF-8') as fout: ->>>>>>> 3adc0218a9cd7f8a7c5930cff50b5d51069d37bb - for line in fout: - line = line.split() - sum = 0 - """ - Разбил строку на слова без пробелов - """ - for i in line: - """ - Каждое слово делю на две части по "(" - Для названия предмета, которое всегда стоит первым элементом в списке, - а так же для случаев, когда стоит прочерк, описываю try - except: - """ - try: - i = i.split('(') - sum += int(i[0]) - except ValueError: - pass - """ - line[0] - первый элемент каждой строки в файле - название предмета - После названия предмета следует ":", поэтому делаю срез строки - """ - unit_dict = {line[0][:-1]: {sum}} - result_dict.update(unit_dict) - print(result_dict) - - -def num7(all_profit=0, count=0, firm_dict={}): - with open('ex7.txt', encoding='UTF - 8') as fout: - for line in fout: - line = line.split() - profit = int(line[2]) - int(line[3]) - if profit > 0: - all_profit += profit - else: - pass - count += 1 - unit_dict = {line[0]: profit} - firm_dict.update(unit_dict) - my_list = [firm_dict, {'Average profit': all_profit / count}] - print(my_list) - """ - json - """ - with open('ex7.json', 'w', encoding='UTF - 8') as fin: - fin.write(json.dumps(my_list)) - - -""" -main(): -""" -q = ' ' -while q != '': - q = input('Введите номер задания или нажмите ENTER: ') - if q == '1': - num1() - elif q == '2': - num2() - elif q == '3': - num3() - elif q == '4': - num4() - elif q == '5': - num5() - elif q == '6': - num6() - elif q == '7': - num7() From 86227dd7617afd3ebd1f5cdf6e81485235eeca6e Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:29:25 +0300 Subject: [PATCH 75/92] Delete ex5.txt --- lesson5/ex5.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lesson5/ex5.txt diff --git a/lesson5/ex5.txt b/lesson5/ex5.txt deleted file mode 100644 index 1d72e45..0000000 --- a/lesson5/ex5.txt +++ /dev/null @@ -1 +0,0 @@ -5 0 1 2 3 7 9 5 6 81 4 56 1 \ No newline at end of file From d5e0c7ccf2ed1fc748b67c88ae8310de55a0ac81 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Tue, 2 Nov 2021 19:06:35 +0300 Subject: [PATCH 76/92] update --- lesson6/ex1.2.py | 20 +++++++++ lesson6/ex1.py | 20 +++++++++ lesson6/ex2.py | 13 ++++++ lesson6/ex3.py | 30 +++++++++++++ lesson6/ex4.py | 103 +++++++++++++++++++++++++++++++++++++++++++ lesson6/ex5.py | 35 +++++++++++++++ lesson6/homework6.py | 6 --- 7 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 lesson6/ex1.2.py create mode 100644 lesson6/ex1.py create mode 100644 lesson6/ex2.py create mode 100644 lesson6/ex3.py create mode 100644 lesson6/ex4.py create mode 100644 lesson6/ex5.py delete mode 100644 lesson6/homework6.py diff --git a/lesson6/ex1.2.py b/lesson6/ex1.2.py new file mode 100644 index 0000000..f286af3 --- /dev/null +++ b/lesson6/ex1.2.py @@ -0,0 +1,20 @@ +from itertools import cycle +import time + + +class TrafficLight: + + _color = ['Красный', 'Желтый', 'Зеленый'] + + def running(self): + for i in cycle(self._color): + print(self._color[0]) + time.sleep(7) + print(self._color[1]) + time.sleep(2) + print(self._color[2]) + time.sleep(7) + + +street = TrafficLight() +print(street.running()) diff --git a/lesson6/ex1.py b/lesson6/ex1.py new file mode 100644 index 0000000..80b8445 --- /dev/null +++ b/lesson6/ex1.py @@ -0,0 +1,20 @@ +from itertools import cycle, count +import time + + +class TrafficLight: + + color = cycle(['Красный', 'Желтый', 'Зеленый']) + + def running(self): + for i in count(): + print(next(self.color)) + time.sleep(7) + print(next(self.color)) + time.sleep(2) + print(next(self.color)) + time.sleep(7) + + +street = TrafficLight() +print(street.running()) diff --git a/lesson6/ex2.py b/lesson6/ex2.py new file mode 100644 index 0000000..950c412 --- /dev/null +++ b/lesson6/ex2.py @@ -0,0 +1,13 @@ +class Road: + + def __init__(self, length, width): + self.__length = length + self.__width = width + + def mass(self, one_layer_mass, layers): + mass = self.__length * self.__width * one_layer_mass * layers + return mass + + +asphalt = Road(20, 200000) +print(f'Масса асфальта: {asphalt.mass(25, 20) / 1000} тонн') diff --git a/lesson6/ex3.py b/lesson6/ex3.py new file mode 100644 index 0000000..16f8590 --- /dev/null +++ b/lesson6/ex3.py @@ -0,0 +1,30 @@ +class Worker: + + def __init__(self, name, surname, position, income={"wage": 1000000, "bonus": 1000000}): + self.name = name + self.surname = surname + self.position = position + self.__income = income + + """ + Достаю приватные оклад и бонус + """ + def get_wage(self): + return self.__income.get("wage") + + def get_bonus(self): + return self.__income.get("bonus") + + +class Position(Worker): + + def get_full_name(self): + print(self.name + ' ' + self.surname) + + def get_total_income(self): + return self.get_wage() + self.get_bonus() + + +worker = Position("Egor", "Ageev", "Teamlead") +worker.get_full_name() +print(worker.get_total_income()) diff --git a/lesson6/ex4.py b/lesson6/ex4.py new file mode 100644 index 0000000..9910d1e --- /dev/null +++ b/lesson6/ex4.py @@ -0,0 +1,103 @@ +class Car: + + def __init__(self, speed, color, name, is_police): + self.speed = speed + self.color = color + self.name = name + self.is_police = is_police + + def go(self): + print(f'{name} едет') + + def stop(self): + print(f'{name} остановилась') + + def turn(self, direction): + print(f'{name} поворачивает на{direction}') + + def show_speed(self): + print(f'Текущая скорость: {self.speed}') + + +class TownCar(Car): + + def show_speed(self): + if 40 <= self.speed <= 60: + print(f'{self.name} движется по городу со скоростью {self.speed}') + elif self.speed > 60: + print(f'{self.name} превышает скоростной режим на {self.speed - 60} км/ч') + else: + print(f'{self.name} едет слишком медленно') + + +class SportCar(Car): + + def show_speed(self): + if 90 < self.speed < 120: + print('Отличная скорость') + elif self.speed > 120: + print('Малыш на драйве') + elif 60 < self.speed < 90: + print('Еду на трек') + else: + print('Паркуюсь') + + def tunning(self, max_speed): + if max_speed < 250: + print('Обратитесь к механику') + else: + print(f'У {self.name} Полный порядок') + + +class WorkCar(Car): + + def show_speed(self): + if self.speed > 40: + print('Сбавьте скорость') + elif 20 <= self.speed <= 40: + print('Придерживайтесь данной скорости') + else: + print(f'{self.name} паркуется') + + +class PoliceCar(Car): + + def call_centre(self): + print('Это полицейский автомобиль. Что у вас случилось?') + + def show_speed(self, police_speed): + if police_speed > 120 and self.speed > 120: + print(f'Догоняю нарушителя на {self.name}') + print(f'Цвет: {self.color}') + print(f'Скорость: {self.speed}') + elif police_speed > 120: + print('Меня угнали') + elif 90 < police_speed < 120: + print('Двигаюсь к месту') + elif 60 < police_speed < 90: + print('Патрулирую') + + +print('для TownCar') +car_1 = TownCar(121, "Silver", "Hyunday", False) +print(f'Марка: {car_1.name}') +car_1.show_speed() + +print('для SportCar') +car_2 = SportCar(180, "Red", "BMW", False) +print(f'Марка: {car_2.name}') +car_2.tunning(270) + +print('для WorkCar') +car_3 = WorkCar(19, "Black", "Mercedes", False) +print(f'Марка: {car_3.name}') +car_3.show_speed() + +print('для PoliceCar') +police = PoliceCar(180, "Black", "Audi", False) +police.call_centre() +police.show_speed(140) + + + + diff --git a/lesson6/ex5.py b/lesson6/ex5.py new file mode 100644 index 0000000..5419471 --- /dev/null +++ b/lesson6/ex5.py @@ -0,0 +1,35 @@ +class Stationery: + + def __init__(self, title): + self.title = title + + def draw(self): + print('Запуск отрисовки') + + +class Pen(Stationery): + + def draw(self): + print(f'Запуск отрисовки {self.title}') + + +class Pencil(Stationery): + + def draw(self): + print(f'Запуск отрисовки {self.title}') + + +class Handle(Stationery): + + def draw(self): + print(f'Запуск отрисовки {self.title}') + + +pen = Pen("ручкой") +pen.draw() + +pencil = Pen("карандашом") +pencil.draw() + +handle = Pen("маркером") +handle.draw() diff --git a/lesson6/homework6.py b/lesson6/homework6.py deleted file mode 100644 index 80e637d..0000000 --- a/lesson6/homework6.py +++ /dev/null @@ -1,6 +0,0 @@ -from itertools import cycle -import time - - -class TrafficLight: - From aa4b9986ff861a8d82698b813f52dc73768cb39d Mon Sep 17 00:00:00 2001 From: Elvirience Date: Tue, 2 Nov 2021 19:14:57 +0300 Subject: [PATCH 77/92] make up changes --- lesson6/ex4.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lesson6/ex4.py b/lesson6/ex4.py index 9910d1e..85c0ddd 100644 --- a/lesson6/ex4.py +++ b/lesson6/ex4.py @@ -97,7 +97,3 @@ def show_speed(self, police_speed): police = PoliceCar(180, "Black", "Audi", False) police.call_centre() police.show_speed(140) - - - - From a8cf8620fb053c4966b5cfc44c706c4ab72a6313 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Tue, 2 Nov 2021 19:18:50 +0300 Subject: [PATCH 78/92] Delete ex1.py --- lesson6/ex1.py | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 lesson6/ex1.py diff --git a/lesson6/ex1.py b/lesson6/ex1.py deleted file mode 100644 index 80b8445..0000000 --- a/lesson6/ex1.py +++ /dev/null @@ -1,20 +0,0 @@ -from itertools import cycle, count -import time - - -class TrafficLight: - - color = cycle(['Красный', 'Желтый', 'Зеленый']) - - def running(self): - for i in count(): - print(next(self.color)) - time.sleep(7) - print(next(self.color)) - time.sleep(2) - print(next(self.color)) - time.sleep(7) - - -street = TrafficLight() -print(street.running()) From 446523f5feefbe26b3e4d5ab49841a48ea3c0570 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Thu, 4 Nov 2021 13:34:41 +0300 Subject: [PATCH 79/92] some changes --- lesson6/ex4.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lesson6/ex4.py b/lesson6/ex4.py index 85c0ddd..7500ae6 100644 --- a/lesson6/ex4.py +++ b/lesson6/ex4.py @@ -7,13 +7,13 @@ def __init__(self, speed, color, name, is_police): self.is_police = is_police def go(self): - print(f'{name} едет') + print(f'{self.name} едет') def stop(self): - print(f'{name} остановилась') + print(f'{self.name} остановилась') def turn(self, direction): - print(f'{name} поворачивает на{direction}') + print(f'{self.name} поворачивает на{direction}') def show_speed(self): print(f'Текущая скорость: {self.speed}') @@ -97,3 +97,7 @@ def show_speed(self, police_speed): police = PoliceCar(180, "Black", "Audi", False) police.call_centre() police.show_speed(140) + +car0 = Car(180, "Red", "BMW", False) +car0.go() +car0.turn("право") From b1b3c2e4186eea5a3a323f42c6e4d2c524cd8efa Mon Sep 17 00:00:00 2001 From: Elvirience Date: Thu, 4 Nov 2021 19:25:45 +0300 Subject: [PATCH 80/92] news --- lesson7/ex1.py | 25 +++++++++++++++++++++++++ lesson7/ex2.py | 42 ++++++++++++++++++++++++++++++++++++++++++ lesson7/ex3.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 lesson7/ex1.py create mode 100644 lesson7/ex2.py create mode 100644 lesson7/ex3.py diff --git a/lesson7/ex1.py b/lesson7/ex1.py new file mode 100644 index 0000000..52e5d4c --- /dev/null +++ b/lesson7/ex1.py @@ -0,0 +1,25 @@ +import math + + +class Matrix: + + def __init__(self, my_matrix): + self.my_matrix = my_matrix + + def __add__(self, other): + result_matrix = [] + for k, l in zip(self.my_matrix, other.my_matrix): + result_list = [] + for m, n in zip(k, l): + result_list.append(m + n) + result_matrix.append(result_list) + return Matrix(result_matrix) + + def __str__(self): + return str(self.my_matrix) + + +a = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) +b = Matrix([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) +c = a + b +print(c) diff --git a/lesson7/ex2.py b/lesson7/ex2.py new file mode 100644 index 0000000..ec09ce3 --- /dev/null +++ b/lesson7/ex2.py @@ -0,0 +1,42 @@ +from abc import ABC, abstractmethod + + +class Clothe(ABC): + def __init__(self, name): + self.name = name + + @property + @abstractmethod + def tissue_consumption(self): + pass + + def __add__(self, other): + return self.tissue_consumption + other.tissue_consumption + + +class TheCoat(Clothe): + def __init__(self, name, V): + super().__init__(name) + self.V = V + + @property + def tissue_consumption(self): + return self.V / 6.5 + 0.5 + + +class TheCostume(Clothe): + def __init__(self, name, H): + super().__init__(name) + self.H = H + + @property + def tissue_consumption(self): + return 2 * self.H + 0.3 + + +clothe_1 = TheCoat("Пальто", 50) +clothe_2 = TheCostume("Костюм", 50) + +print(f'Расход ткани на пальто: {clothe_1.tissue_consumption}') +print(f'Расход ткани на костюм: {clothe_2.tissue_consumption}') +print(f'Общий расход ткани: {clothe_1 + clothe_2}') diff --git a/lesson7/ex3.py b/lesson7/ex3.py new file mode 100644 index 0000000..205cab2 --- /dev/null +++ b/lesson7/ex3.py @@ -0,0 +1,29 @@ +from math import ceil + + +class Cell: + def __init__(self, quantity): + self.quantitiy = quantity + + def __add__(self, other): + return self.quantitiy + other.quantity + + def __sub__(self, other): + res = self.quantitiy - other.quantity + if res >= 0: + return self.quantitiy - other.quantity + else: + return print("Разность количества клеток отрицтельна") + + def __mul__(self, other): + new_cell = self.quantitiy * other.quantity + return new_cell + + def __truediv__(self, other): + new_cell = ceil(self.quantitiy / other.quantity) + return new_cell + + def make_order(self, row): + my_list = [] + for i in range(row): + From d483ddb5b23a1b16da04ebc1c6ede26b11a91190 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 4 Nov 2021 19:26:31 +0300 Subject: [PATCH 81/92] Delete ex1.2.py --- lesson6/ex1.2.py | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 lesson6/ex1.2.py diff --git a/lesson6/ex1.2.py b/lesson6/ex1.2.py deleted file mode 100644 index f286af3..0000000 --- a/lesson6/ex1.2.py +++ /dev/null @@ -1,20 +0,0 @@ -from itertools import cycle -import time - - -class TrafficLight: - - _color = ['Красный', 'Желтый', 'Зеленый'] - - def running(self): - for i in cycle(self._color): - print(self._color[0]) - time.sleep(7) - print(self._color[1]) - time.sleep(2) - print(self._color[2]) - time.sleep(7) - - -street = TrafficLight() -print(street.running()) From f648df204391f059ec10957da64d0bf2064e5887 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 4 Nov 2021 19:26:42 +0300 Subject: [PATCH 82/92] Delete ex2.py --- lesson6/ex2.py | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 lesson6/ex2.py diff --git a/lesson6/ex2.py b/lesson6/ex2.py deleted file mode 100644 index 950c412..0000000 --- a/lesson6/ex2.py +++ /dev/null @@ -1,13 +0,0 @@ -class Road: - - def __init__(self, length, width): - self.__length = length - self.__width = width - - def mass(self, one_layer_mass, layers): - mass = self.__length * self.__width * one_layer_mass * layers - return mass - - -asphalt = Road(20, 200000) -print(f'Масса асфальта: {asphalt.mass(25, 20) / 1000} тонн') From ff6be9e2aade5645dad5efa41ffdea8edf62b02b Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 4 Nov 2021 19:26:47 +0300 Subject: [PATCH 83/92] Delete ex3.py --- lesson6/ex3.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 lesson6/ex3.py diff --git a/lesson6/ex3.py b/lesson6/ex3.py deleted file mode 100644 index 16f8590..0000000 --- a/lesson6/ex3.py +++ /dev/null @@ -1,30 +0,0 @@ -class Worker: - - def __init__(self, name, surname, position, income={"wage": 1000000, "bonus": 1000000}): - self.name = name - self.surname = surname - self.position = position - self.__income = income - - """ - Достаю приватные оклад и бонус - """ - def get_wage(self): - return self.__income.get("wage") - - def get_bonus(self): - return self.__income.get("bonus") - - -class Position(Worker): - - def get_full_name(self): - print(self.name + ' ' + self.surname) - - def get_total_income(self): - return self.get_wage() + self.get_bonus() - - -worker = Position("Egor", "Ageev", "Teamlead") -worker.get_full_name() -print(worker.get_total_income()) From 25cc60bce09c892a775c811be32dae7edbd2f305 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 4 Nov 2021 19:26:53 +0300 Subject: [PATCH 84/92] Delete ex4.py --- lesson6/ex4.py | 103 ------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 lesson6/ex4.py diff --git a/lesson6/ex4.py b/lesson6/ex4.py deleted file mode 100644 index 7500ae6..0000000 --- a/lesson6/ex4.py +++ /dev/null @@ -1,103 +0,0 @@ -class Car: - - def __init__(self, speed, color, name, is_police): - self.speed = 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): - print(f'Текущая скорость: {self.speed}') - - -class TownCar(Car): - - def show_speed(self): - if 40 <= self.speed <= 60: - print(f'{self.name} движется по городу со скоростью {self.speed}') - elif self.speed > 60: - print(f'{self.name} превышает скоростной режим на {self.speed - 60} км/ч') - else: - print(f'{self.name} едет слишком медленно') - - -class SportCar(Car): - - def show_speed(self): - if 90 < self.speed < 120: - print('Отличная скорость') - elif self.speed > 120: - print('Малыш на драйве') - elif 60 < self.speed < 90: - print('Еду на трек') - else: - print('Паркуюсь') - - def tunning(self, max_speed): - if max_speed < 250: - print('Обратитесь к механику') - else: - print(f'У {self.name} Полный порядок') - - -class WorkCar(Car): - - def show_speed(self): - if self.speed > 40: - print('Сбавьте скорость') - elif 20 <= self.speed <= 40: - print('Придерживайтесь данной скорости') - else: - print(f'{self.name} паркуется') - - -class PoliceCar(Car): - - def call_centre(self): - print('Это полицейский автомобиль. Что у вас случилось?') - - def show_speed(self, police_speed): - if police_speed > 120 and self.speed > 120: - print(f'Догоняю нарушителя на {self.name}') - print(f'Цвет: {self.color}') - print(f'Скорость: {self.speed}') - elif police_speed > 120: - print('Меня угнали') - elif 90 < police_speed < 120: - print('Двигаюсь к месту') - elif 60 < police_speed < 90: - print('Патрулирую') - - -print('для TownCar') -car_1 = TownCar(121, "Silver", "Hyunday", False) -print(f'Марка: {car_1.name}') -car_1.show_speed() - -print('для SportCar') -car_2 = SportCar(180, "Red", "BMW", False) -print(f'Марка: {car_2.name}') -car_2.tunning(270) - -print('для WorkCar') -car_3 = WorkCar(19, "Black", "Mercedes", False) -print(f'Марка: {car_3.name}') -car_3.show_speed() - -print('для PoliceCar') -police = PoliceCar(180, "Black", "Audi", False) -police.call_centre() -police.show_speed(140) - -car0 = Car(180, "Red", "BMW", False) -car0.go() -car0.turn("право") From ab29f80a4c7db5e72c5e05d7bf3867d78c05b7a9 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Thu, 4 Nov 2021 19:27:03 +0300 Subject: [PATCH 85/92] Delete ex5.py --- lesson6/ex5.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 lesson6/ex5.py diff --git a/lesson6/ex5.py b/lesson6/ex5.py deleted file mode 100644 index 5419471..0000000 --- a/lesson6/ex5.py +++ /dev/null @@ -1,35 +0,0 @@ -class Stationery: - - def __init__(self, title): - self.title = title - - def draw(self): - print('Запуск отрисовки') - - -class Pen(Stationery): - - def draw(self): - print(f'Запуск отрисовки {self.title}') - - -class Pencil(Stationery): - - def draw(self): - print(f'Запуск отрисовки {self.title}') - - -class Handle(Stationery): - - def draw(self): - print(f'Запуск отрисовки {self.title}') - - -pen = Pen("ручкой") -pen.draw() - -pencil = Pen("карандашом") -pencil.draw() - -handle = Pen("маркером") -handle.draw() From 45102efc99982903c8b2b6de1d7490f7fa2af129 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Thu, 4 Nov 2021 19:46:14 +0300 Subject: [PATCH 86/92] update --- lesson7/ex3.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lesson7/ex3.py b/lesson7/ex3.py index 205cab2..5c28f6b 100644 --- a/lesson7/ex3.py +++ b/lesson7/ex3.py @@ -24,6 +24,24 @@ def __truediv__(self, other): return new_cell def make_order(self, row): - my_list = [] - for i in range(row): - + my_matrix = [] + a = self.quantitiy % row + if a == 0: + for i in range(self.quantitiy / row): + my_list = [] + for j in range(row): + my_list.append('*') + my_matrix.append(''.join(my_list)) + '/n'.join(my_matrix) + else: + for i in range(self.quantitiy / row): + my_list = [] + for j in range(row): + my_list.append('*') + my_matrix.append(''.join(my_list)) + my_list = [] + for el in range(a): + my_list.append('*') + my_matrix.append(''.join(my_list)) + '/n'.join(my_matrix) + \ No newline at end of file From 3339dbbba31a5a53893cbb93aba2669ec898598d Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 5 Nov 2021 23:12:17 +0300 Subject: [PATCH 87/92] corrects --- lesson7/ex3.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lesson7/ex3.py b/lesson7/ex3.py index 5c28f6b..aef6026 100644 --- a/lesson7/ex3.py +++ b/lesson7/ex3.py @@ -27,14 +27,14 @@ def make_order(self, row): my_matrix = [] a = self.quantitiy % row if a == 0: - for i in range(self.quantitiy / row): + for i in range(self.quantitiy // row): my_list = [] for j in range(row): my_list.append('*') my_matrix.append(''.join(my_list)) - '/n'.join(my_matrix) + return '/n'.join(my_matrix) else: - for i in range(self.quantitiy / row): + for i in range(self.quantitiy // row): my_list = [] for j in range(row): my_list.append('*') @@ -43,5 +43,8 @@ def make_order(self, row): for el in range(a): my_list.append('*') my_matrix.append(''.join(my_list)) - '/n'.join(my_matrix) - \ No newline at end of file + return '/n'.join(my_matrix) + + +a = Cell(40) +print(a.make_order(6)) From 780bd638086ef446401e9ea381224359473b4afe Mon Sep 17 00:00:00 2001 From: Elvirience Date: Fri, 5 Nov 2021 23:15:05 +0300 Subject: [PATCH 88/92] final --- lesson7/ex3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lesson7/ex3.py b/lesson7/ex3.py index aef6026..eeed78e 100644 --- a/lesson7/ex3.py +++ b/lesson7/ex3.py @@ -32,7 +32,7 @@ def make_order(self, row): for j in range(row): my_list.append('*') my_matrix.append(''.join(my_list)) - return '/n'.join(my_matrix) + return '\n'.join(my_matrix) else: for i in range(self.quantitiy // row): my_list = [] @@ -43,7 +43,7 @@ def make_order(self, row): for el in range(a): my_list.append('*') my_matrix.append(''.join(my_list)) - return '/n'.join(my_matrix) + return '\n'.join(my_matrix) a = Cell(40) From 3439c5ae04169cebef14670941d9944a2f8d3335 Mon Sep 17 00:00:00 2001 From: Elvirience Date: Mon, 8 Nov 2021 01:43:06 +0300 Subject: [PATCH 89/92] new files --- lesson8/ex1.py | 35 ++++++++++++ lesson8/ex2.py | 18 ++++++ lesson8/ex3.py | 31 +++++++++++ lesson8/ex456.py | 141 +++++++++++++++++++++++++++++++++++++++++++++++ lesson8/ex7.py | 24 ++++++++ 5 files changed, 249 insertions(+) create mode 100644 lesson8/ex1.py create mode 100644 lesson8/ex2.py create mode 100644 lesson8/ex3.py create mode 100644 lesson8/ex456.py create mode 100644 lesson8/ex7.py diff --git a/lesson8/ex1.py b/lesson8/ex1.py new file mode 100644 index 0000000..837a577 --- /dev/null +++ b/lesson8/ex1.py @@ -0,0 +1,35 @@ +from datetime import date + + +class Data: + + def __init__(self, data): + self.data = data + + @classmethod + def transformer(cls, data): + lst = data.split('-') + new_lst = [int(i) for i in lst] + return cls(new_lst) + + @property + def your_data(self): + return print(f'Вы ввели: {self.data}') + + @staticmethod + def validity(month, year): + if 1 <= month <= 12: + pass + else: + print('Неправильный месяц') + if year != date.today().year: + print('Неактуальный год') + + def __del__(self): + print('Деструктор сработал') + + +Data.validity(7, 2025) +b = Data.transformer('12-13-2021') +b.your_data +print(type(b.data)) diff --git a/lesson8/ex2.py b/lesson8/ex2.py new file mode 100644 index 0000000..a7ed059 --- /dev/null +++ b/lesson8/ex2.py @@ -0,0 +1,18 @@ +class MyExcept(Exception): + def __init__(self, txt): + self.txt = txt + + def __del__(self): + pass + + +try: + a = int(input('Числитель: ')) + b = int(input('Знаменатель: ')) + if b == 0: + raise MyExcept('Деление на ноль!') + res = a/b +except MyExcept as error: + print(error) +else: + print(f'Ответ: {res}') diff --git a/lesson8/ex3.py b/lesson8/ex3.py new file mode 100644 index 0000000..dd6fc8d --- /dev/null +++ b/lesson8/ex3.py @@ -0,0 +1,31 @@ +class NumeralException(Exception): + def __init__(self, txt): + self.txt = txt + + def __del__(self): + pass + + +lst = [] +i = input('Введите элемент списка: ') +while i != 'q': + try: + if i.isdigit() is True: + lst.append(int(i)) + else: + """ + Если не число, то проверяю на float + Если одно из "if" не сработает, выпадет исключение + """ + check = i.split('.') + if len(check) == 2: + if check[0].isdigit() and check[1].isdigit(): + lst.append(float(i)) + else: + break + else: + raise(NumeralException('Вы ввели не число!')) + except NumeralException as error: + print(error) + i = input('Введите элемент списка: ') +print(lst) diff --git a/lesson8/ex456.py b/lesson8/ex456.py new file mode 100644 index 0000000..7a2f00a --- /dev/null +++ b/lesson8/ex456.py @@ -0,0 +1,141 @@ +class OfficeEquipment: + + """ + Атрибуты, используемые в методах "warehouse", "transportation" + """ + my_dict = {} + names = [] + quantities = [] + prices = [] + + """ + По сценарию объект класса находится в оффисе, но может быть взят со склада. + В коде программы я заполнил склад и забрал оттуда нужные товары, + попутно выполнив небольшие методы классов-наследников + """ + def __init__(self, name, quantity, price): + self.name = name + self.quantity = quantity + self.price = price + print('Атрибут поступил в оффис') + + def needs(self, staff): + if self.quantity < staff: + spend = self.price * (staff - self.quantity) + print(f'Необходимо закупить {self.name} на сумму {spend} руб') + else: + print('Закупки не требуются') + + """ + Метод для 6-го номера + Он проверяет вводимость числа + Использовал его в методе "warehouse", контролируя данные, вводимые в реестр склада + """ + @staticmethod + def validator(parametr): + if type(parametr) is str: + while parametr.isdigit() is False: + parametr = input('Введите число!') + return int(parametr) + else: + return int(parametr) + + """ + Проверяю являются ли количесвто и цена, введенные пользователем, числами + если нет, предлагаю повторить ввод + Если на складе уже есть товар с таким названием, то список с названиями остается прежним, + а количество обновляется (определяется индекс введенного названия товара в списке, где оно уже есть + и по этому индексу в списке с количествами соответствующих товаров выбирается нужное нам и складывается + с введенным) + Далее формируется словарь (реестр склада) + """ + @classmethod + def warehouse(cls, name, quantity, price): + cls.validator(quantity) + cls.validator(price) + if cls.names.count(name) >= 1: + index = cls.names.index(name) + value = cls.quantities[index] + cls.quantities[index] = value + quantity + else: + cls.names.append(name) + cls.quantities.append(quantity) + cls.prices.append(price) + cls.my_dict = {'Наименование': cls.names, 'Цена': cls.prices, 'Количество': cls.quantities} + print(f"Атрибут '{name}' вписан в реестр склада") + return cls.my_dict + + """ + После пополнения склада методом "warehouse" появляется словарь (реестр) my_dict + Его значения - списки с данными (названия, количество, цена) + В методе "transportation" извлекается ключ-список по соответсвующему значению + затем проверяется, если на складе товар "name". + Если есть, то определяется индекс его названия в списке + и по этому индексу берется соотвествующее нужному товару количество. + Из количества товара на складе вычитается необходимое, + если разность при этом останется больше нуля. + Полученная разность становится в словаре "my_dict" на место прежнего значения количества, + что сопровождается соответствующим сообщением + """ + @classmethod + def transportation(cls, name, quantity): + lst = cls.my_dict.get('Наименование') + if lst.count(name) == 0: + print(f"Атрибут '{name}' отсутсвтует на складе") + else: + index = lst.index(name) + cls.quantities[index] = cls.my_dict.get('Количество')[index] - quantity + if cls.quantities[index] > 0: + cls.my_dict = {'Наименование': cls.names, 'Цена': cls.prices, 'Количество': cls.quantities} + print(f"{quantity} атрибутов '{name}' взято со склада ") + print('Реестр склада обновлен') + return cls.my_dict + else: + print(f"Атрибут {name} закончился") + + def __del__(self): + pass + + +class PC(OfficeEquipment): + def __init__(self, name, quantity, price, os): + super().__init__(name, quantity, price) + self.os = os + + @classmethod + def os_choice(cls): + cls.os = input('Введите название ОС: ') + print('Вы перешли на новую операционную систему') + return cls.os + + +class Printer(OfficeEquipment): + def __init__(self, name, quantity, price, paper): + super().__init__(name, quantity, price) + self.paper = paper + + def condition(self): + if self.paper is False: + print('Нужна бумага') + else: + pass + + +class Cartridge(OfficeEquipment): + @property + def condition(self): + if self.quantity < 20: + print('Нужно больше картриджей') + else: + pass + + +a = OfficeEquipment.warehouse('PC', 325, 526436) +b = OfficeEquipment.warehouse('Принтер', 214, 5264) +c = OfficeEquipment.warehouse('PC', 325, 526436) +print(OfficeEquipment.my_dict) +d = OfficeEquipment.transportation('PC', 20) +e = PC('laptop', 2134, 200000, 'windows') +e = PC.os_choice() +e = PC.warehouse('laptop', 2134, 200000) +e = PC.transportation('laptop', 1) diff --git a/lesson8/ex7.py b/lesson8/ex7.py new file mode 100644 index 0000000..a2c3df1 --- /dev/null +++ b/lesson8/ex7.py @@ -0,0 +1,24 @@ +class ComplexNumber: + def __init__(self, x, y): + self.x = x + self.y = y + + def __str__(self): + return f'{self.x} + {self.y * 1j}' + + def __add__(self, other): + return (self.x + other.x) + (self.y + other.y) * 1j + + def __mul__(self, other): + return (self.x * other.x - self.y * other.y) + (self.x * other.y + other.x * self.y) * 1j + + def __del__(self): + pass + + +num1 = ComplexNumber(5, 6) +print(num1) +num2 = ComplexNumber(6, 7) +print(num2) +print(num1 + num2) +print(num1 * num2) From 0fa686ac37f3db5cbf2772f7b21a9c531633e7e3 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 8 Nov 2021 01:43:54 +0300 Subject: [PATCH 90/92] Delete ex1.py --- lesson7/ex1.py | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 lesson7/ex1.py diff --git a/lesson7/ex1.py b/lesson7/ex1.py deleted file mode 100644 index 52e5d4c..0000000 --- a/lesson7/ex1.py +++ /dev/null @@ -1,25 +0,0 @@ -import math - - -class Matrix: - - def __init__(self, my_matrix): - self.my_matrix = my_matrix - - def __add__(self, other): - result_matrix = [] - for k, l in zip(self.my_matrix, other.my_matrix): - result_list = [] - for m, n in zip(k, l): - result_list.append(m + n) - result_matrix.append(result_list) - return Matrix(result_matrix) - - def __str__(self): - return str(self.my_matrix) - - -a = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) -b = Matrix([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) -c = a + b -print(c) From b12aa6d1af99a39b0aa6f5bcfad3db50674a8676 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 8 Nov 2021 01:44:11 +0300 Subject: [PATCH 91/92] Delete ex2.py --- lesson7/ex2.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 lesson7/ex2.py diff --git a/lesson7/ex2.py b/lesson7/ex2.py deleted file mode 100644 index ec09ce3..0000000 --- a/lesson7/ex2.py +++ /dev/null @@ -1,42 +0,0 @@ -from abc import ABC, abstractmethod - - -class Clothe(ABC): - def __init__(self, name): - self.name = name - - @property - @abstractmethod - def tissue_consumption(self): - pass - - def __add__(self, other): - return self.tissue_consumption + other.tissue_consumption - - -class TheCoat(Clothe): - def __init__(self, name, V): - super().__init__(name) - self.V = V - - @property - def tissue_consumption(self): - return self.V / 6.5 + 0.5 - - -class TheCostume(Clothe): - def __init__(self, name, H): - super().__init__(name) - self.H = H - - @property - def tissue_consumption(self): - return 2 * self.H + 0.3 - - -clothe_1 = TheCoat("Пальто", 50) -clothe_2 = TheCostume("Костюм", 50) - -print(f'Расход ткани на пальто: {clothe_1.tissue_consumption}') -print(f'Расход ткани на костюм: {clothe_2.tissue_consumption}') -print(f'Общий расход ткани: {clothe_1 + clothe_2}') From 4e8cc6d15366e82f0b08889ec1f4f90158f0a171 Mon Sep 17 00:00:00 2001 From: Elvirience <92172008+Elvirience@users.noreply.github.com> Date: Mon, 8 Nov 2021 01:44:24 +0300 Subject: [PATCH 92/92] Delete ex3.py --- lesson7/ex3.py | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 lesson7/ex3.py diff --git a/lesson7/ex3.py b/lesson7/ex3.py deleted file mode 100644 index eeed78e..0000000 --- a/lesson7/ex3.py +++ /dev/null @@ -1,50 +0,0 @@ -from math import ceil - - -class Cell: - def __init__(self, quantity): - self.quantitiy = quantity - - def __add__(self, other): - return self.quantitiy + other.quantity - - def __sub__(self, other): - res = self.quantitiy - other.quantity - if res >= 0: - return self.quantitiy - other.quantity - else: - return print("Разность количества клеток отрицтельна") - - def __mul__(self, other): - new_cell = self.quantitiy * other.quantity - return new_cell - - def __truediv__(self, other): - new_cell = ceil(self.quantitiy / other.quantity) - return new_cell - - def make_order(self, row): - my_matrix = [] - a = self.quantitiy % row - if a == 0: - for i in range(self.quantitiy // row): - my_list = [] - for j in range(row): - my_list.append('*') - my_matrix.append(''.join(my_list)) - return '\n'.join(my_matrix) - else: - for i in range(self.quantitiy // row): - my_list = [] - for j in range(row): - my_list.append('*') - my_matrix.append(''.join(my_list)) - my_list = [] - for el in range(a): - my_list.append('*') - my_matrix.append(''.join(my_list)) - return '\n'.join(my_matrix) - - -a = Cell(40) -print(a.make_order(6))