From d27394b502fef8d6a8879e64728a267c66974af0 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Thu, 17 Oct 2024 01:29:00 +0300 Subject: [PATCH] Initial commit --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 126 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 83 +++++++++++++++++++++++++++++ app/labs/lab1.py | 0 app/labs/lab2.py | 0 app/labs/lab3.py | 0 app/labs/lab4.py | 0 app/labs/lab5.py | 0 app/labs/labTest.py | 59 +++++++++++++++++++++ app/menu_load.py | 72 +++++++++++++++++++++++++ app/utils/config.py | 1 + app/utils/system.py | 10 ++++ main.py | 11 ++++ requirements.txt | 2 + 14 files changed, 364 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app/labs/lab1.py create mode 100644 app/labs/lab2.py create mode 100644 app/labs/lab3.py create mode 100644 app/labs/lab4.py create mode 100644 app/labs/lab5.py create mode 100644 app/labs/labTest.py create mode 100644 app/menu_load.py create mode 100644 app/utils/config.py create mode 100644 app/utils/system.py create mode 100644 main.py create mode 100644 requirements.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a55fbe6e056816ee940c8995e723189c326537dc GIT binary patch literal 6148 zcmeHK-EI;=6h2dqWx*J^FrgP-?2U;RwOOPs^baXQOj9*Rj9#c|7a^7eb`ch_B8D5^ zL45-s#V7DVd;tCCN7LPE(ko+hPIBfuGv|D>?61}Nkl;j>mRY@sKovt|{r3jFN~$Zt1AJ`HHF*Nc6>pOCrwO_{ohH1$!}rGQpY zeH^bA`9yVw?o)$ysZMu*E8w={4BARCax|n4y`V9!A)`J#pom6bNA!xKIA6R=@EKJd zR441cChF3hXOCCmJ6z_q_^j$zy+3)^@#@xOG%#!2=hmRt9Yvn^MJ%NF++x~svf1o~ z?9=8^IB7EOK`#uRBO_ULzRYV};|gTkCzm%7ZSxJj&37@n##KmJ z;c{vbxe6E1_s~|5+vGCFq)WLy-h$*M_R!x3ZxubvMb}VWM*SANi0Bq_yOPTdRO&~y z!~5JwJS_Q&o_tv7T06S}=7n(1pPgbWtpZko|3m?~KDcm+RfBVlYUx0ujsQT$urkEz z&p*(W1Hh`mxkik@gr)*DRhT1&FlPs$>Bv`2{amA_lTcU2Jm$*6oKS>0dI(pQlc;L6 ztyRD(5LY0jyE(c4H-3NqkCSZADqt1(rxXxeZ`NzLC9}7lx;eSmy6{7|G+8&-s3>U6 icB}%q6)(Y+A?L~fST#7;h!L3mBcNokjaA@}D)1eS0JQf2 literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8da64c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,126 @@ +# devmusor +test_module/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..de8db48 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +metodi +============= + +bts metodi 1 + +-------- + +### Windows + +1. *Installing Git and Python:* + +* [Git for Windows](https://git-scm.com/downloads/) +* [Download python 3.x](https://www.python.org/downloads/) + +2. *Cloning the Repository:* + + git clone https://git.dota2.pw/cheykrym/metodi.git + cd metodi + +3. *Creating a Virtual Environment:* + + python -m venv env + +4. *Installing Dependencies:* + + .\env\Scripts\pip.exe install -r .\requirements.txt + +5. *Running the Project:* + + .\env\Scripts\python.exe .\main.py + +### Mac + +1. *Installing Git and Python:* + + - + +2. *Cloning the Repository:* + + git clone https://git.dota2.pw/cheykrym/metodi.git + cd metodi + +3. *Creating a Virtual Environment:* + + python3 -m venv env + +4. *Installing Dependencies:* + + . ./env/bin/activate + pip3 install -r requirements.txt + deactivate + +5. *Running the Project:* + + env/bin/python3 main.py + +### Linux + +1. *Installing Git and Python:* + + sudo apt update + sudo apt -y install git + sudo apt -y install python3 + sudo apt -y install python3-pip + +2. *Cloning the Repository:* + + git clone https://git.dota2.pw/cheykrym/metodi.git + cd metodi + +3. *Creating a Virtual Environment:* + + python3 -m venv env + +4. *Installing Dependencies:* + + . ./env/bin/activate + pip3 install -r requirements.txt + deactivate + +5. *Running the Project:* + + env/bin/python3 main.py diff --git a/app/labs/lab1.py b/app/labs/lab1.py new file mode 100644 index 0000000..e69de29 diff --git a/app/labs/lab2.py b/app/labs/lab2.py new file mode 100644 index 0000000..e69de29 diff --git a/app/labs/lab3.py b/app/labs/lab3.py new file mode 100644 index 0000000..e69de29 diff --git a/app/labs/lab4.py b/app/labs/lab4.py new file mode 100644 index 0000000..e69de29 diff --git a/app/labs/lab5.py b/app/labs/lab5.py new file mode 100644 index 0000000..e69de29 diff --git a/app/labs/labTest.py b/app/labs/labTest.py new file mode 100644 index 0000000..bb5e11c --- /dev/null +++ b/app/labs/labTest.py @@ -0,0 +1,59 @@ +import math + + +class labTest: + + def __init__(self): + pass # Конструктор пока пустой, при необходимости можно добавить параметры + + def calc_roots(self, a, b, c): + if a == 0: + raise ValueError("Невозможно найти корни, так как уравнение не является квадратным.") + + # дискриминант + discriminant = b ** 2 - 4 * a * c + print(f"Дискриминант равен {discriminant:.2f}, ", end='') + + if discriminant > 0: + print("уравнение имеет 2 различных вещественных корня.") + # Два различных корня + x1 = (-b + math.sqrt(discriminant)) / (2 * a) + x2 = (-b - math.sqrt(discriminant)) / (2 * a) + return [round(x1, 2), round(x2, 2)] + + elif discriminant == 0: + print("уравнение имеет 1 вещественный корень.") + # Один корень + x = -b / (2 * a) + return [round(x, 2)] + + else: + print("уравнение не имеет вещественных корней.") + # Нет вещественных корней + return [] + + # Коэффициенты уравнения + # a, b, c = 0, -3, 2 // 1 -3 2 + + def main(self, a, b, c): + try: + X = self.calc_roots(a, b, c) + if X: + print(f"Корни уравнения: {', '.join(map(str, X))}.") + else: + print("Корни уравнения отсутствуют.") + except ValueError as e: + print(e) + + def start(self): + try: + a = int(input("Введите a: ")) + b = int(input("Введите b: ")) + c = int(input("Введите c: ")) + self.main(a, b, c) + except ValueError: + print("Ошибка ввода: необходимо ввести целые числа для a, b и c.") + +if __name__ == "__main__": + lab_test = labTest() + lab_test.start() diff --git a/app/menu_load.py b/app/menu_load.py new file mode 100644 index 0000000..45ef70d --- /dev/null +++ b/app/menu_load.py @@ -0,0 +1,72 @@ +from app.utils.system import clear_console + +# from app.zadachi.lab1 import lab1 +# from app.zadachi.lab2 import lab2 +# from app.zadachi.lab3 import lab3 +# from app.zadachi.lab4 import lab4 +# from app.zadachi.lab5 import lab5 +# from app.zadachi.lab6 import lab6 +# from app.zadachi.lab7 import lab7 +from app.labs.labTest import labTest + +class menu: + + def __init__(self): + pass # Конструктор пока пустой, при необходимости можно добавить параметры + + def main_menu(self): + clear_console() + while True: + print('\nMain Menu:') + print('1. Задача 1 (Не работает)') + print('2. Задача 2 (Не работает)') + print('3. Задача 3 (Не работает)') + print('4. Задача 4 (Не работает)') + print('5. Задача 5 (Не работает)') + print('6. Задача 6 (Не работает)') + print('7. Задача 7 (Не работает)') + print('8. Задача Test') + print('0. Exit') + + choice = input('Select an option: ') + + clear_console() + if choice == '1': + pass + # elif choice == '2': + # self.lab2_menu() # Переход к подменю Задачи 2 + # elif choice == '3': + # self.lab3_menu() # Переход к подменю Задачи 3 + # elif choice == '4': + # self.lab4_menu() # Добавлен вызов меню задачи 4 + elif choice == '8': + self.labTest_menu() # Добавлен вызов меню задачи 5 + elif choice == '0': + print('Exiting program...') + break + else: + print('Invalid option') + + + + def labTest_menu(self): + """Меню для задачи Тест""" + clear_console() + lT = labTest() + + while True: + print('\nЗадача Тест:') + print('1. Рассчитать значение дискриминанта и по результату выдать в консоль сообщение, сколько вещественных корней имеет уравнение.') + print('0. Назад') + + choice = input('Выберите подкатегорию: ') + + clear_console() + + if choice == '1': + + lT.start() + elif choice == '0': + break + else: + print('Неверный выбор, попробуйте снова.') diff --git a/app/utils/config.py b/app/utils/config.py new file mode 100644 index 0000000..c5b5026 --- /dev/null +++ b/app/utils/config.py @@ -0,0 +1 @@ +debug=0 diff --git a/app/utils/system.py b/app/utils/system.py new file mode 100644 index 0000000..b2b3aac --- /dev/null +++ b/app/utils/system.py @@ -0,0 +1,10 @@ +import os +import platform + +def clear_console(): + """Очистить консоль в зависимости от операционной системы.""" + os_name = platform.system() + if os_name == 'Windows': + os.system('cls') + else: + os.system('clear') diff --git a/main.py b/main.py new file mode 100644 index 0000000..a088d68 --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +from app.utils.config import debug +from app.menu_load import menu + +if __name__ == "__main__": + if debug == True: + print("Running in debug mode...") + from test_module.debug_main import debug_main_start + debug_main_start() + else: + mn = menu() + mn.main_menu() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..49ef8f1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +numpy==2.1.2 +matplotlib==3.9.2