From bd6c3da8d9f1758b24dda2e1d018cef2ae3a45cd Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:12:06 +0300 Subject: [PATCH 1/7] README --- README.md | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 1e89314..8f78370 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,5 @@ -# Контрольная работа 1 (1 вариант) - -Темы: Git и GitHub, стандарты оформления кода, хорошие практики, тестирование. - -## Этапы выполнения работы - -- Сделать **fork** этого репозитория - - Добавить недостающие файлы для "хорошо оформленного" репозитория -- Исправить ошибки, из-за которых не проходит CI -- Найти и исправить баг(и), которые есть в `src/fast_pow.py` и `src/luhn.py` - - Добавить исключения в соответствующих случаях (например, когда степень в `fast_pow` отрицательная) - - Исправить и/или дополнить тесты так, чтобы они покрывали найденные ошибки - - Для каждого бага должен быть отдельный **commit** с его исправлением, в его описании должно быть пояснение (можно на русском) решённой проблемы -- На основе [алгоритма Луна](https://ru.wikipedia.org/wiki/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%9B%D1%83%D0%BD%D0%B0) реализовать простую консольную утилиту - - Пользователь вводит в консоль номер карточки $\to$ ему выводится "correct" или "incorrect" в зависимости от правильности номера - - Выход из утилиты происходит по вводу пользователем `-1` - - Ошибки не должны прерывать прерывать работу утилиты, но пользователь должен быть уведомлен о том, что он сделал что-то не так - - Реализация утилиты должна быть в модуле `src/luhn.py` -- Сделать **pull request** (один на обе задачи) с решением в main ветку этого репозитория - - **pull request** должен содержать описание проделанной работы, ваше ФИО и номер группы - - Если не получилось/забыли сделать адекватное описание исправленных ошибок в описании к **commit**, то нужно сделать это хотя бы в комментариях к **pull request** +Контрольная работа №1 по Python; +Кочанов Андрей; +Python 3.13.7; +tg @chempufcfor; +st142099@student.spbu.ru From bd1c48efbc34808460d1295419133d44bb0d3ae2 Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:12:43 +0300 Subject: [PATCH 2/7] gitignore --- .gitignore | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09be0ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,207 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[codz] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +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 +*.spec + +# 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 +*.py.cover +.hypothesis/ +.pytest_cache/ +cover/ + +# 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 +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .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 + +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock +#poetry.toml + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. +# https://pdm-project.org/en/latest/usage/project/#working-with-version-control +#pdm.lock +#pdm.toml +.pdm-python +.pdm-build/ + +# pixi +# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. +#pixi.lock +# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one +# in the .venv directory. It is recommended not to include this directory in version control. +.pixi + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.envrc +.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/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# Abstra +# Abstra is an AI-powered process automation framework. +# Ignore directories containing user credentials, local state, and settings. +# Learn more at https://abstra.io/docs +.abstra/ + +# Visual Studio Code +# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore +# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +# and can be added to the global gitignore or merged into this file. However, if you prefer, +# you could uncomment the following to ignore the entire vscode folder +# .vscode/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc + +# Cursor +# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to +# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data +# refer to https://docs.cursor.com/context/ignore-files +.cursorignore +.cursorindexingignore + +# Marimo +marimo/_static/ +marimo/_lsp/ +__marimo__/ From f308594c0aa47925218df1ce5fe9b95159162fdc Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:13:11 +0300 Subject: [PATCH 3/7] =?UTF-8?q?=D0=9B=D0=B8=D0=B7=D0=B5=D0=BD=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2f41828 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Andrew-Kochanov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From e29fea5580c4e0dac700440225a427d5b6890f4e Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:13:56 +0300 Subject: [PATCH 4/7] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D1=83=D1=82?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luhn.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/luhn.py b/src/luhn.py index 11d993c..e9ede1e 100644 --- a/src/luhn.py +++ b/src/luhn.py @@ -12,3 +12,25 @@ def luhnСheck(cardNumber): else: total += digits[i] return (total + control) % 10 == 0 + + +def utility(cardNumber): + cardNumber = input('Введите номер карты(или -1, чтобы выйти)') + flag = False + while cardNumber != "-1": + if flag: + print("Вы неправильно ввели номер карты, будте внимательны") + cardNumber = input('Введите номер карты(или -1, чтобы выйти):') + for i in range(len(cardNumber)): + if i % 4 == 0: + if cardNumber != " ": + flag = True + else: + if cardNumber[i] not in '1234567890': + flag = True + if not flag: + if luhnСheck(cardNumber): + print("Correct") + else: + print("Incorect") + cardNumber = input('Введите номер карты(или -1, чтобы выйти):') From be02b56cbc9b9b525a40a396804d661a160a98f9 Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:15:01 +0300 Subject: [PATCH 5/7] =?UTF-8?q?=D0=91=D1=8B=D1=81=D1=82=D1=80=D0=BE=D0=B5?= =?UTF-8?q?=20=D0=B2=D0=BE=D0=B7=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B2=20=D1=81=D1=82=D0=B5=D0=BF=D0=B5=D0=BD=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Сделал так, чтобы result умножался на number --- src/fast_pow.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index 1ba1dc1..8c71835 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -1,6 +1,9 @@ def fastPow(number, power): result = number while power != 1: - result *= result - power = power // 2 + result *= number + power = power - 1 + print(result, power) return result + + From fc45d6bc9c0ba9f6824e19e1666481206c975644 Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:17:02 +0300 Subject: [PATCH 6/7] pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e8c1a14..9dec7a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,4 +17,4 @@ [tool.pytest.ini_options] testpaths = "test" -pythonpath = '.' \ No newline at end of file +pythonpath = '.' From a6fd82b56ed10adc04c78d36eeaf7384e2c2c061 Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Thu, 23 Oct 2025 15:18:07 +0300 Subject: [PATCH 7/7] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=20ruff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ruff.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 164630d..49da7c6 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,8 +1,18 @@ name: Ruff -on: [push, pull_request] +on: push jobs: - ruff: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: astral-sh/ruff-action@v3 + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff + # Update output format to enable automatic inline annotations. + - name: Run Ruff + run: ruff check --output-format=github .