From add02f65de727050283c0cdd127530443c76f3d4 Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Tue, 13 Sep 2022 21:05:25 +0300 Subject: [PATCH 1/8] Test task --- Practice/Bezborody/lec1_task1.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 Practice/Bezborody/lec1_task1.py diff --git a/Practice/Bezborody/lec1_task1.py b/Practice/Bezborody/lec1_task1.py new file mode 100644 index 0000000..2f9a147 --- /dev/null +++ b/Practice/Bezborody/lec1_task1.py @@ -0,0 +1 @@ +print("Hello") From bacb2039d9958731fe659ce3efd32c25280c868b Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Tue, 13 Sep 2022 21:16:55 +0300 Subject: [PATCH 2/8] Test task --- Practice/Bezborody/lec1_task1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/Bezborody/lec1_task1.py b/Practice/Bezborody/lec1_task1.py index 2f9a147..d800f10 100644 --- a/Practice/Bezborody/lec1_task1.py +++ b/Practice/Bezborody/lec1_task1.py @@ -1 +1 @@ -print("Hello") +print("Hello1") From c089c188c911fd4af8dd80953132b6b1aff45492 Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Wed, 14 Sep 2022 22:12:25 +0300 Subject: [PATCH 3/8] Test task --- Practice/Bezborody/lec1_task4.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Practice/Bezborody/lec1_task4.py diff --git a/Practice/Bezborody/lec1_task4.py b/Practice/Bezborody/lec1_task4.py new file mode 100644 index 0000000..eb623bf --- /dev/null +++ b/Practice/Bezborody/lec1_task4.py @@ -0,0 +1,3 @@ +name = input("Введите имя: ") +fullname = input("Введите фамилию: ") +print(f"Echo: {name} {fullname}") \ No newline at end of file From 8841a5434b771483cdd52f71778aba5f066a5097 Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Wed, 14 Sep 2022 23:04:05 +0300 Subject: [PATCH 4/8] Lecture 2 task 1 --- Practice/Bezborody/lec2_task1.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Practice/Bezborody/lec2_task1.py diff --git a/Practice/Bezborody/lec2_task1.py b/Practice/Bezborody/lec2_task1.py new file mode 100644 index 0000000..6a2ba33 --- /dev/null +++ b/Practice/Bezborody/lec2_task1.py @@ -0,0 +1,9 @@ +import math +def square(r): + return math.pi * r ** 2 +radius = input("Введите радиус: ") +result = square(int(radius)) +print(f"Площадь круга: {result}") + + + From 024b9bfbd3f3c89fe960f0e29d643f5bb31913f4 Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Thu, 15 Sep 2022 00:10:48 +0300 Subject: [PATCH 5/8] PEP8 minor edit --- Practice/Bezborody/lec1_task2.py | 6 ++++++ Practice/Bezborody/lec2_task1.py | 1 + 2 files changed, 7 insertions(+) create mode 100644 Practice/Bezborody/lec1_task2.py diff --git a/Practice/Bezborody/lec1_task2.py b/Practice/Bezborody/lec1_task2.py new file mode 100644 index 0000000..b76b8d0 --- /dev/null +++ b/Practice/Bezborody/lec1_task2.py @@ -0,0 +1,6 @@ +start = input("Топлива было: ") +end = input("Топлива осталось: ") +distance = input("Расстояние: ") +diff = int(start) - int(end) +result = diff / distance +print \ No newline at end of file diff --git a/Practice/Bezborody/lec2_task1.py b/Practice/Bezborody/lec2_task1.py index 6a2ba33..099ef14 100644 --- a/Practice/Bezborody/lec2_task1.py +++ b/Practice/Bezborody/lec2_task1.py @@ -1,6 +1,7 @@ import math def square(r): return math.pi * r ** 2 + radius = input("Введите радиус: ") result = square(int(radius)) print(f"Площадь круга: {result}") From 5b49deeded0bf80ab5baf412ef04bdf69d65d57a Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Tue, 20 Sep 2022 22:43:31 +0300 Subject: [PATCH 6/8] Some Pep8-related comments --- Practice/Bezborody/pep8task.py | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Practice/Bezborody/pep8task.py diff --git a/Practice/Bezborody/pep8task.py b/Practice/Bezborody/pep8task.py new file mode 100644 index 0000000..60d8e5b --- /dev/null +++ b/Practice/Bezborody/pep8task.py @@ -0,0 +1,69 @@ +import sys +import os +import hashlib +import ast +import argparse +from time import * # звездочка не указывает, вроде бы, на то, что импортируется + + +class shuffler: # нарушено правило CamelCase + + def __init__(self): + self.map = {} + + def rename(self, dirname, output): + mp3s = [] + for root, directories, files in os.walk(dirname): + for file in files: + if file[-3:] == '.mp3': + mp3s.append([root, file]) + for path, mp3 in mp3s: + hashname = self.generateName() + '.mp3' + self.map[hashname] = mp3 + os.rename(path + '/' + mp3), path + '/' + hashname)) + f = open(output, 'r') # нарушение уровней вложенности (2 пробела вместо 4) + f.write(str(self.map)) # тоже нарушены уровни вложенности + + def restore(self, dirname, restore_path): + with open(filename, '+') as f: #уровни вложенности + self.map = ast.literal_eval(f.read()) # уровни вложенности + mp3s = [] # уровни вложенности + for root, directories, files in os.walk(dirname): + for file in files: + if file[-3:] == '.mp3': # уровни вложенности + mp3s.append({root, file}) # уровни вложенности + for path, hashname in mp3s: + os.rename(path + '/' + hashname, path + '/' + self.map[hashname])) # лишняя скобка + os.remove(restore_path) + + def generateName(self, seed=time()): # уровни вложенности + generate и name дожны быть набраны через snake case + return hashlib.md5(str(seed)).hexdigest() + + +def parse_arguments(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest='subcommand', help='subcommand help') + rename_parser = subparsers.add_parser('rename', help='rename help') + rename_parser.add_argument('dirname') + rename_parser.add_argument('-o', '--output', help='path to a file where restore map is stored') + restore_parser = subparsers.add_parser('restore', help="command_a help") + restore_parser.add_argument('dirname') + restore_parser.add_argument('restore_map') + args = parser.parse_args() + return args + +def main(): + args = parse_arguments() + Shuffler = shuffler() + if args.subcommand == 'rename': + if args.output: + Shuffler.rename(args.dirname, 'restore.info') + else: + Shuffler.rename(args.dirname, args.output) + elif args.subcommand == 'restore': + Shuffler.restore(args.dirname, args.restore_map) + else: + sys.exit() + + +main() From 530fadfb43dae51d98f9b44afd64bc630b514feb Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Wed, 21 Sep 2022 22:09:08 +0300 Subject: [PATCH 7/8] Some Pep8-related comments --- Practice/Bezborody/pep8task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/Bezborody/pep8task.py b/Practice/Bezborody/pep8task.py index 60d8e5b..1c2b8e3 100644 --- a/Practice/Bezborody/pep8task.py +++ b/Practice/Bezborody/pep8task.py @@ -3,7 +3,7 @@ import hashlib import ast import argparse -from time import * # звездочка не указывает, вроде бы, на то, что импортируется +from time import * # такой import не рекомендуется PEP8 class shuffler: # нарушено правило CamelCase From c0b94ce6fcef87ee8b4552356e4d5e80769131e4 Mon Sep 17 00:00:00 2001 From: Bezborodyi Date: Wed, 21 Sep 2022 23:05:57 +0300 Subject: [PATCH 8/8] With edits --- Practice/Bezborody/lec1_task2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Practice/Bezborody/lec1_task2.py b/Practice/Bezborody/lec1_task2.py index b76b8d0..451e648 100644 --- a/Practice/Bezborody/lec1_task2.py +++ b/Practice/Bezborody/lec1_task2.py @@ -2,5 +2,5 @@ end = input("Топлива осталось: ") distance = input("Расстояние: ") diff = int(start) - int(end) -result = diff / distance -print \ No newline at end of file +result = int(diff) / int(distance) +print (f"Расход топлива {result}") \ No newline at end of file