From 467c3cd55e6a844f5791198fd6009859552f91b5 Mon Sep 17 00:00:00 2001 From: YurchenkoSerhiy Date: Fri, 10 Dec 2021 09:15:12 +0200 Subject: [PATCH 1/2] lab_0 lab_1 students.rst READMY.rst --- dk91_yurchenko/README.rst | 8 ++++++++ dk91_yurchenko/lab_0/Lab_0.py | 20 ++++++++++++++++++++ dk91_yurchenko/lab_1/lab_1.py | 27 +++++++++++++++++++++++++++ students.rst | 1 + 4 files changed, 56 insertions(+) create mode 100644 dk91_yurchenko/README.rst create mode 100644 dk91_yurchenko/lab_0/Lab_0.py create mode 100644 dk91_yurchenko/lab_1/lab_1.py diff --git a/dk91_yurchenko/README.rst b/dk91_yurchenko/README.rst new file mode 100644 index 0000000..e313e45 --- /dev/null +++ b/dk91_yurchenko/README.rst @@ -0,0 +1,8 @@ +Student: Yurchenko Serhiy + +University: National Technical University of Ukraine «Igor Sikorsky Kyiv Polytechnic Institute» +Group: DK-91 + +Contacts: +Telegram: `@Sergey1ner `_ +Email: yurchsergeyne@gmail.com \ No newline at end of file diff --git a/dk91_yurchenko/lab_0/Lab_0.py b/dk91_yurchenko/lab_0/Lab_0.py new file mode 100644 index 0000000..7eca2b9 --- /dev/null +++ b/dk91_yurchenko/lab_0/Lab_0.py @@ -0,0 +1,20 @@ +print('Limit area: ', end='') +l=int(input()) +a=float(input("Enter the area of the object1: ")) +b=float(input("Enter the area of the object2 (not less 2): ")) +c=float(input("Enter the area of the object3 (not less 3): ")) +while True: + s = a + b + c + if s <= l: + if b < 2: + print('Object2 area less than 2') + break + elif c < 3: + print('Object3 area less than 3') + break + else: + print('The area will be enough.') + break + else: + print('The area of ​​the objects exceeds the allowable area!') + break diff --git a/dk91_yurchenko/lab_1/lab_1.py b/dk91_yurchenko/lab_1/lab_1.py new file mode 100644 index 0000000..a192456 --- /dev/null +++ b/dk91_yurchenko/lab_1/lab_1.py @@ -0,0 +1,27 @@ +#! /usr/bin/env python3 +"""Area calculator""" +def standard(b,c): + """Compliance check function.""" + if b < 2: + print('Object2 area less than 2') + else: + print('Object2 comply with the standard.') + if c < 3: + print('Object3 area less than 3') + else: + print('Object3 comply with the standard.') + +import argparse +parser = argparse.ArgumentParser() +"""Positional arguments""" +parser.add_argument('l', type=int, help='Limit area') +parser.add_argument('a', type=float, help='Enter the area of the object1') +parser.add_argument('b', type=float, help='Enter the area of the object2 (not less 2)') +parser.add_argument('c', type=float, help='Enter the area of the object2 (not less 3)') +args = parser.parse_args() +standard(args.b, args.c) +s = args.a + args.b + args.c +if s <= args.l: + print('The area will be enough.') +else: + print('The area of the objects exceeds the allowable area!') diff --git a/students.rst b/students.rst index e66921f..412f5d1 100644 --- a/students.rst +++ b/students.rst @@ -6,5 +6,6 @@ Student Directory ================== ========================================= Anton Romanenko `dk92_romanenko `_ Artem Herashchenko `dk91_herashchenko `_ +Sergiy Yurchenko `dk91_yurchenko `_ ================== ========================================= From ea50195b38c76a94b5e1a149edbc94d6185256aa Mon Sep 17 00:00:00 2001 From: YurchenkoSerhiy Date: Fri, 24 Dec 2021 22:57:44 +0200 Subject: [PATCH 2/2] mkr2 --- dk91_yurchenko/mkr2/READMY.rst | 17 +++++++++++++++ dk91_yurchenko/mkr2/mkr2.py | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 dk91_yurchenko/mkr2/READMY.rst create mode 100644 dk91_yurchenko/mkr2/mkr2.py diff --git a/dk91_yurchenko/mkr2/READMY.rst b/dk91_yurchenko/mkr2/READMY.rst new file mode 100644 index 0000000..1948fc5 --- /dev/null +++ b/dk91_yurchenko/mkr2/READMY.rst @@ -0,0 +1,17 @@ +1. Написать скрипт, реализующий игру "угадай мелодию". + + Суть игры в следующем. Есть директория ``musdir`` с MP3-файлами песен. + Из директории случайным образом выбирается песня. Из нее случайным образом + выбирается фрагмент длительностью ``len`` секунд и воспроизводится пользователю. + + Пользователю предлагается угадать, что это за песня. В случае верного ответа, + игрок набирает очки. В случае неверного – игрок проигрывает, ему предлагается сыграть снова. + + Вести учет максимальных очков (highscore). + + Для работы с файлами использовать стандартную библиотеку ``pathlib``. + + Для работы с аудио можно использовать любую из стандартных (лучше – сторонних) + библиотек. Решение должно быть мультиплатформенным (Windows, GNU/Linux). + + Значения параметров принимать в виде аргументов командной строки. \ No newline at end of file diff --git a/dk91_yurchenko/mkr2/mkr2.py b/dk91_yurchenko/mkr2/mkr2.py new file mode 100644 index 0000000..4524359 --- /dev/null +++ b/dk91_yurchenko/mkr2/mkr2.py @@ -0,0 +1,38 @@ +#! /usr/bin/env python3 + +from pathlib import Path +from random import randint +from pydub import AudioSegment +from pydub.playback import play +import argparse + +def game(highscore): + + r = randint(1, 5) + i = 0 + + pathlist = Path.home().glob('**/musdir/*.mp3') + for path in pathlist: + i = i + 1 + path_in_str = str(path) + print(path_in_str) + if(i == r): + path_in_str = str(path) + sound = AudioSegment.from_mp3(path_in_str) + play(sound) + + print('What played out of this?') + + parser = argparse.ArgumentParser() + """Positional arguments""" + parser.add_argument('l', type=int, help='Track number: ') + args = parser.parse_args() + + if(args.l == r): + print('GOOD!') + highscore = highscore + 1 + game(highscore) + else: + print('Highscore: ', highscore) + +game(0)