Compare commits
No commits in common. "main" and "master" have entirely different histories.
162
.gitignore
vendored
162
.gitignore
vendored
@ -1,162 +0,0 @@
|
|||||||
# ---> Python
|
|
||||||
# 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/
|
|
||||||
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
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# pdm
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
||||||
#pdm.lock
|
|
||||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
||||||
# in version control.
|
|
||||||
# https://pdm.fming.dev/#use-with-ide
|
|
||||||
.pdm.toml
|
|
||||||
|
|
||||||
# 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
|
|
||||||
.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/
|
|
||||||
|
|
||||||
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
8
.idea/PythonProject1.iml
generated
Normal file
8
.idea/PythonProject1.iml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.14" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -3,4 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.14" />
|
<option name="sdkName" value="Python 3.14" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.14" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/PythonProject1.iml" filepath="$PROJECT_DIR$/.idea/PythonProject1.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
154
.idea/workspace.xml
generated
154
.idea/workspace.xml
generated
@ -1,154 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ChangeListManager">
|
|
||||||
<list default="true" id="e3ba60a3-0f42-4117-8bc2-cfac75d2e9bc" name="Changes" comment="update main" />
|
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
||||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
||||||
</component>
|
|
||||||
<component name="FileTemplateManagerImpl">
|
|
||||||
<option name="RECENT_TEMPLATES">
|
|
||||||
<list>
|
|
||||||
<option value="Python Script" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="Git.Settings">
|
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
||||||
</component>
|
|
||||||
<component name="ProblemsViewState">
|
|
||||||
<option name="selectedTabId" value="CurrentFile" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectColorInfo">{
|
|
||||||
"associatedIndex": 4
|
|
||||||
}</component>
|
|
||||||
<component name="ProjectId" id="3BrUUzXZnJIJlj3S50JwsEWF25r" />
|
|
||||||
<component name="ProjectViewState">
|
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
|
||||||
<option name="showLibraryContents" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="PropertiesComponent">{
|
|
||||||
"keyToString": {
|
|
||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
|
||||||
"Python.main.executor": "Run",
|
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
|
||||||
"ai.playground.ignore.import.keys.banner.in.settings": "true",
|
|
||||||
"git-widget-placeholder": "main",
|
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
|
||||||
"nodejs_package_manager_path": "npm",
|
|
||||||
"settings.editor.selected.configurable": "configurable.group.editor",
|
|
||||||
"vue.rearranger.settings.migration": "true"
|
|
||||||
}
|
|
||||||
}</component>
|
|
||||||
<component name="RunManager">
|
|
||||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="MyPractice" />
|
|
||||||
<option name="ENV_FILES" value="" />
|
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
|
||||||
<option name="PARENT_ENVS" value="true" />
|
|
||||||
<envs>
|
|
||||||
<env name="PYTHONUNBUFFERED" value="1" />
|
|
||||||
</envs>
|
|
||||||
<option name="SDK_HOME" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
|
||||||
<option name="IS_MODULE_SDK" value="true" />
|
|
||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
|
||||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
||||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
|
||||||
<option name="RUN_TOOL" value="" />
|
|
||||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
|
||||||
<option name="EMULATE_TERMINAL" value="false" />
|
|
||||||
<option name="MODULE_MODE" value="false" />
|
|
||||||
<option name="REDIRECT_INPUT" value="false" />
|
|
||||||
<option name="INPUT_FILE" value="" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<recent_temporary>
|
|
||||||
<list>
|
|
||||||
<item itemvalue="Python.main" />
|
|
||||||
</list>
|
|
||||||
</recent_temporary>
|
|
||||||
</component>
|
|
||||||
<component name="SharedIndexes">
|
|
||||||
<attachedChunks>
|
|
||||||
<set>
|
|
||||||
<option value="bundled-js-predefined-d6986cc7102b-9b0f141eb926-JavaScript-PY-253.30387.173" />
|
|
||||||
<option value="bundled-python-sdk-4762d8aabb82-6d6dccd035ac-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-253.30387.173" />
|
|
||||||
</set>
|
|
||||||
</attachedChunks>
|
|
||||||
</component>
|
|
||||||
<component name="TaskManager">
|
|
||||||
<task active="true" id="Default" summary="Default task">
|
|
||||||
<changelist id="e3ba60a3-0f42-4117-8bc2-cfac75d2e9bc" name="Changes" comment="" />
|
|
||||||
<created>1775246703281</created>
|
|
||||||
<option name="number" value="Default" />
|
|
||||||
<option name="presentableId" value="Default" />
|
|
||||||
<updated>1775246703281</updated>
|
|
||||||
<workItem from="1775246704513" duration="2431000" />
|
|
||||||
<workItem from="1776422295448" duration="1958000" />
|
|
||||||
<workItem from="1776426591556" duration="6573000" />
|
|
||||||
<workItem from="1776442655564" duration="782000" />
|
|
||||||
<workItem from="1776443460648" duration="1884000" />
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00001" summary="make start files">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1775249257265</created>
|
|
||||||
<option name="number" value="00001" />
|
|
||||||
<option name="presentableId" value="LOCAL-00001" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1775249257265</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00002" summary="update">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1776443190676</created>
|
|
||||||
<option name="number" value="00002" />
|
|
||||||
<option name="presentableId" value="LOCAL-00002" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1776443190676</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00003" summary="update">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1776443228265</created>
|
|
||||||
<option name="number" value="00003" />
|
|
||||||
<option name="presentableId" value="LOCAL-00003" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1776443228265</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00004" summary="update">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1776443742206</created>
|
|
||||||
<option name="number" value="00004" />
|
|
||||||
<option name="presentableId" value="LOCAL-00004" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1776443742206</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00005" summary="update main">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1776443836846</created>
|
|
||||||
<option name="number" value="00005" />
|
|
||||||
<option name="presentableId" value="LOCAL-00005" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1776443836846</updated>
|
|
||||||
</task>
|
|
||||||
<option name="localTasksCounter" value="6" />
|
|
||||||
<servers />
|
|
||||||
</component>
|
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
|
||||||
<option name="version" value="3" />
|
|
||||||
</component>
|
|
||||||
<component name="VcsManagerConfiguration">
|
|
||||||
<MESSAGE value="make start files" />
|
|
||||||
<MESSAGE value="update" />
|
|
||||||
<MESSAGE value="update main" />
|
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="update main" />
|
|
||||||
</component>
|
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
|
||||||
<SUITE FILE_PATH="coverage/MyPractice$main.coverage" NAME="main Coverage Results" MODIFIED="1776435625444" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
Ноутбук,Электроника,1200,5,2024-01-15
|
|
||||||
Мышь,Электроника,25,15,2024-01-20
|
|
||||||
Клавиатура,Электроника,45,10,2024-02-10
|
|
||||||
Кофеварка,Техника,150,3,2024-02-15
|
|
||||||
Футболка,Одежда,20,50,2024-02-20
|
|
||||||
Джинсы,Одежда,60,20,2024-03-05
|
|
||||||
Лампа,Дом,35,12,2024-03-12
|
|
||||||
Чайник,Техника,80,8,2024-03-20
|
|
||||||
Монитор,Электроника,300,4,2024-04-01
|
|
||||||
Носки,Одежда,5,100,2024-04-05
|
|
||||||
Рюкзак,Аксессуары,55,15,2024-04-10
|
|
||||||
Книга,Хобби,15,30,2024-01-25
|
|
||||||
Блокнот,Хобби,8,40,2024-02-01
|
|
||||||
Ручка,Хобби,2,200,2024-02-05
|
|
||||||
Коврик для йоги,Спорт,25,20,2024-03-15
|
|
||||||
Гантели,Спорт,40,10,2024-04-12
|
|
||||||
Наушники,Электроника,90,12,2024-04-18
|
|
||||||
Сковорода,Дом,45,6,2024-01-30
|
|
||||||
Подушка,Дом,25,14,2024-02-28
|
|
||||||
Зеркало,Дом,110,2,2024-03-25
|
|
||||||
|
126
main.py
126
main.py
@ -1,117 +1,11 @@
|
|||||||
import csv
|
import math
|
||||||
from collections import defaultdict
|
def lcm(a: int, b: int) -> int:
|
||||||
|
if a == 0 or b == 0:
|
||||||
|
return 0
|
||||||
def load_data(filepath: str) -> list[dict]:
|
return abs(a * b) // math.gcd(a, b)
|
||||||
records = []
|
|
||||||
with open(filepath, mode='r', encoding='utf-8') as f:
|
|
||||||
reader = csv.reader(f)
|
|
||||||
for row in reader:
|
|
||||||
if not row: continue
|
|
||||||
name, category, price, quantity, date = row
|
|
||||||
records.append({
|
|
||||||
"name": name.strip(),
|
|
||||||
"category": category.strip(),
|
|
||||||
"price": float(price),
|
|
||||||
"quantity": int(quantity),
|
|
||||||
"date": date.strip()
|
|
||||||
})
|
|
||||||
return records
|
|
||||||
|
|
||||||
|
|
||||||
def clean_data(records: list[dict]) -> list[dict]:
|
|
||||||
cleaned = []
|
|
||||||
for r in records:
|
|
||||||
if r['price'] >= 0 and r['quantity'] >= 0:
|
|
||||||
r['category'] = r['category'].lower()
|
|
||||||
cleaned.append(r)
|
|
||||||
return cleaned
|
|
||||||
|
|
||||||
|
|
||||||
def filter_by_category(records: list[dict], category: str) -> list[dict]:
|
|
||||||
return [r for r in records if r['category'] == category.lower()]
|
|
||||||
|
|
||||||
|
|
||||||
def filter_by_price_range(records: list[dict], min_price: float, max_price: float) -> list[dict]:
|
|
||||||
return [r for r in records if min_price <= r['price'] <= max_price]
|
|
||||||
|
|
||||||
|
|
||||||
def total_revenue(records: list[dict]) -> float:
|
|
||||||
return sum(r['price'] * r['quantity'] for r in records)
|
|
||||||
|
|
||||||
|
|
||||||
def category_revenue(records: list[dict]) -> dict[str, float]:
|
|
||||||
rev_map = defaultdict(float)
|
|
||||||
for r in records:
|
|
||||||
rev_map[r['category']] += r['price'] * r['quantity']
|
|
||||||
return dict(rev_map)
|
|
||||||
|
|
||||||
|
|
||||||
def top_n_items(records: list[dict], n: int) -> list[tuple[str, int]]:
|
|
||||||
counts = defaultdict(int)
|
|
||||||
for r in records:
|
|
||||||
counts[r['name']] += r['quantity']
|
|
||||||
sorted_items = sorted(counts.items(), key=lambda x: x[1], reverse=True)
|
|
||||||
return sorted_items[:n]
|
|
||||||
|
|
||||||
|
|
||||||
def monthly_sales(records: list[dict]) -> dict[str, float]:
|
|
||||||
monthly_rev = defaultdict(float)
|
|
||||||
for r in records:
|
|
||||||
month = r['date'][:7] # Извлекает YYYY-MM
|
|
||||||
monthly_rev[month] += r['price'] * r['quantity']
|
|
||||||
return dict(sorted(monthly_rev.items()))
|
|
||||||
|
|
||||||
|
|
||||||
def best_selling_category(records: list[dict]) -> str:
|
|
||||||
cat_rev = category_revenue(records)
|
|
||||||
if not cat_rev: return ""
|
|
||||||
return max(cat_rev, key=cat_rev.get)
|
|
||||||
|
|
||||||
|
|
||||||
def export_summary(records: list[dict], output_path: str) -> None:
|
|
||||||
rev = total_revenue(records)
|
|
||||||
best_cat = best_selling_category(records)
|
|
||||||
top3 = top_n_items(records, 3)
|
|
||||||
monthly = monthly_sales(records)
|
|
||||||
|
|
||||||
with open(output_path, 'w', encoding='utf-8') as f:
|
|
||||||
f.write("СВОДНЫЙ ОТЧЕТ ПО ПРОДАЖАМ\n")
|
|
||||||
f.write("=" * 30 + "\n")
|
|
||||||
f.write(f"Общая выручка: {rev:.2f}\n")
|
|
||||||
f.write(f"Лучшая категория: {best_cat}\n\n")
|
|
||||||
f.write("Топ-3 товара (по количеству):\n")
|
|
||||||
for name, qty in top3:
|
|
||||||
f.write(f"- {name}: {qty} шт.\n")
|
|
||||||
f.write("\nВыручка по месяцам:\n")
|
|
||||||
for month, m_rev in monthly.items():
|
|
||||||
f.write(f"- {month}: {m_rev:.2f}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
#Пометки для себя любимого
|
|
||||||
#Загрузка
|
|
||||||
data = load_data("data/sales.csv")
|
|
||||||
#Очистка
|
|
||||||
data = clean_data(data)
|
|
||||||
#Фильтрация
|
|
||||||
filtered = filter_by_price_range(data, 10, 500)
|
|
||||||
#Анализ
|
|
||||||
rev = total_revenue(filtered)
|
|
||||||
cat_rev = category_revenue(filtered)
|
|
||||||
best_cat = best_selling_category(filtered)
|
|
||||||
top3 = top_n_items(filtered, 3)
|
|
||||||
monthly = monthly_sales(filtered)
|
|
||||||
#Вывод в консоль
|
|
||||||
print(f"--- Результаты анализа (фильтр: 10-500 руб) ---")
|
|
||||||
print(f"Общая выручка: {rev:.2f}")
|
|
||||||
print(f"Лучшая категория: {best_cat.capitalize()}")
|
|
||||||
print(f"Топ-3 товара: {top3}")
|
|
||||||
print(f"Выручка по месяцам: {monthly}")
|
|
||||||
#Экспорт
|
|
||||||
export_summary(filtered, "report.txt")
|
|
||||||
print(f"\nОтчет успешно сохранен в report.txt")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
num1 = 4
|
||||||
|
num2 = 6
|
||||||
|
result = lcm(num1, num2)
|
||||||
|
print(f"Наибольшее общее кратное двух чисел {num1} и {num2} равно {result}")
|
||||||
|
|
||||||
|
|||||||
17
report.txt
17
report.txt
@ -1,15 +1,4 @@
|
|||||||
СВОДНЫЙ ОТЧЕТ ПО ПРОДАЖАМ
|
"C:\Program Files\Python314\python.exe" C:\Users\USER\PycharmProjects\PythonProject1\main.py
|
||||||
==============================
|
Наибольшее общее кратное двух чисел 4 и 6 равно 12
|
||||||
Общая выручка: 9830.00
|
|
||||||
Лучшая категория: электроника
|
|
||||||
|
|
||||||
Топ-3 товара (по количеству):
|
Process finished with exit code 0
|
||||||
- Футболка: 50 шт.
|
|
||||||
- Книга: 30 шт.
|
|
||||||
- Джинсы: 20 шт.
|
|
||||||
|
|
||||||
Выручка по месяцам:
|
|
||||||
- 2024-01: 1095.00
|
|
||||||
- 2024-02: 2250.00
|
|
||||||
- 2024-03: 2980.00
|
|
||||||
- 2024-04: 3505.00
|
|
||||||
Loading…
Reference in New Issue
Block a user