This repository contains exercises for the GridU Python Basic course.
practice/— weekly module tasks (m1–m7)capstone/— final Console Data Generator project
Both parts share the same dependencies and the same virtual environment. Set up the environment once at the repository root, then run practice scripts, capstone commands, and tests from there.
- Python 3.11+ (see
pyproject.toml) git
PYTHON-BASIC/
├── practice/ # Course exercises by module
│ ├── m1_python_part_1/
│ ├── m2_python_part_2/
│ ├── m3_python_testing/
│ ├── m4_python_part_3/
│ ├── m5_additional_topics/
│ ├── m6_web_scraping/
│ └── m7_concurrency/
├── capstone/ # Capstone project (data generator CLI)
├── requirements.txt # Shared dependencies for practice and capstone
├── pyproject.toml # Ruff configuration
└── pytest.ini # Pytest configuration
Some modules include their own README.md with task-specific instructions (for example practice/m6_web_scraping/ or practice/m5_additional_topics/parsing_serialization_task/).
Use one virtual environment at the repository root for both practice/ and capstone/.
git clone <repository-url>
cd PYTHON-BASICmacOS / Linux:
python3 -m venv .venvWindows (Command Prompt):
python -m venv .venvWindows (PowerShell):
python -m venv .venvmacOS / Linux:
source .venv/bin/activateWindows (Command Prompt):
.venv\Scripts\activate.batWindows (PowerShell):
.venv\Scripts\Activate.ps1Your shell prompt should show (.venv) when the environment is active.
python -m pip install --upgrade pip
pip install -r requirements.txtpre-commit installThis runs Ruff and basic file checks automatically before each commit.
deactivateAlways run commands from the repository root with the virtual environment activated.
Most early tasks are standalone scripts:
python practice/m1_python_part_1/task1.py
python practice/m2_python_part_2/task_classes.pyTasks that import other project modules must be run as packages:
python -m practice.m6_web_scraping.main
python -m practice.m6_web_scraping.standalone_api
python -m practice.m5_additional_topics.parsing_serialization_task.task_jsonConcurrency templates:
python -m practice.m7_concurrency.task1_fibonacci.template
python -m practice.m7_concurrency.task2_apod_api.template| Module | Notes |
|---|---|
m5_additional_topics/parsing_serialization_task |
See module README. Validate XML with python practice/m5_additional_topics/parsing_serialization_task/tests/validate_xml.py. |
m6_web_scraping |
Requires network access. See module README. |
m7_concurrency/task2_apod_api |
Requires a NASA API key. Store it with keyring: keyring set nasa_concurrent_task NASA_API_KEY. |
Run the Console Data Generator CLI:
python -m capstone.mainShow available options and defaults:
python -m capstone.main --helpExample with custom arguments:
python -m capstone.main \
--path_to_save_files ./capstone/output \
--files_count 2 \
--file_name export \
--data_lines 5Default values are loaded from capstone/default.ini. Generated files are written to capstone/output/ by default.
Tests use pytest. Run them from the repository root with the virtual environment activated.
pytestor:
python -m pytestpytest practice/Practice tests live mainly in practice/m3_python_testing/ and practice/m6_web_scraping/test_scraper.py.
pytest capstone/pytest practice/m3_python_testing/test_task_classes.py
pytest capstone/test_app.py
pytest practice/m3_python_testing/test_task_parametrize.py::test_fibonacci_2
pytest practice/m3_python_testing/test_task_classes.py::TestTeacher::test_initpytest -v # verbose output
pytest -q # quiet output
pytest -x # stop on first failure
pytest --collect-only # list tests without running themNot every module has automated tests. Use the table below to run tests for the task you are working on.
| Module | Task / topic | What to run |
|---|---|---|
| m1 | task1–task6 |
No automated tests — run scripts manually, e.g. python practice/m1_python_part_1/task1.py |
| m2 | task_read_write |
pytest practice/m3_python_testing/test_read_write.py |
| m2 | task_read_write_2 |
pytest practice/m3_python_testing/test_read_write_2.py |
| m2 | task_exceptions |
pytest practice/m3_python_testing/test_task_exceptions.py |
| m2 | task_input_output |
pytest practice/m3_python_testing/test_task_input_output.py |
| m2 | task_classes |
pytest practice/m3_python_testing/test_task_classes.py |
| m3 | All testing exercises | pytest practice/m3_python_testing/ |
| m3 | Parametrize (test_task_parametrize) |
pytest practice/m3_python_testing/test_task_parametrize.py |
| m4 | task_1 |
pytest practice/m4_python_part_3/task_1.py |
| m4 | task_2 |
pytest practice/m4_python_part_3/task_2.py |
| m4 | task_3 |
pytest practice/m4_python_part_3/task_3.py |
| m4 | task_4 |
pytest practice/m4_python_part_3/task_4.py |
| m4 | task_5 |
pytest practice/m4_python_part_3/task_5.py |
| m4 | All m4 tasks | pytest practice/m4_python_part_3/ |
| m5 | XML parsing (parsing_serialization_task) |
python practice/m5_additional_topics/parsing_serialization_task/tests/validate_xml.py |
| m6 | Web scraping | pytest practice/m6_web_scraping/test_scraper.py |
| m7 | Fibonacci / APOD API | No automated tests — run templates manually (see Running commands) |
| capstone | Console Data Generator | pytest capstone/test_app.py |
Examples — run one test inside a file:
# Single test function
pytest practice/m3_python_testing/test_task_exceptions.py::test_division_by_zero
# Single test method in a test class
pytest practice/m3_python_testing/test_task_classes.py::TestStudent::test_is_active_before_dealine
# Single parametrized case (by index)
pytest practice/m3_python_testing/test_task_parametrize.py::test_fibonacci_2[3]
# Single capstone test
pytest capstone/test_app.py::test_inline_argumentsNote: m2 tasks are tested via files in practice/m3_python_testing/ — that module contains the tests you write (or run) for m2 homework.