python-lab-toolkit 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_lab_toolkit-1.0.0/LICENSE +21 -0
- python_lab_toolkit-1.0.0/PKG-INFO +427 -0
- python_lab_toolkit-1.0.0/README.md +387 -0
- python_lab_toolkit-1.0.0/pyproject.toml +66 -0
- python_lab_toolkit-1.0.0/setup.cfg +4 -0
- python_lab_toolkit-1.0.0/setup.py +4 -0
- python_lab_toolkit-1.0.0/src/pylab/__init__.py +43 -0
- python_lab_toolkit-1.0.0/src/pylab/cli.py +282 -0
- python_lab_toolkit-1.0.0/src/pylab/data/Data.csv +11 -0
- python_lab_toolkit-1.0.0/src/pylab/data/alphabet_stock_data.csv +143 -0
- python_lab_toolkit-1.0.0/src/pylab/data/breast-cancer.csv +351 -0
- python_lab_toolkit-1.0.0/src/pylab/data/dirtydata.csv +33 -0
- python_lab_toolkit-1.0.0/src/pylab/data/groceries.csv +359 -0
- python_lab_toolkit-1.0.0/src/pylab/data/iris.csv +151 -0
- python_lab_toolkit-1.0.0/src/pylab/data/rainfall.csv +151 -0
- python_lab_toolkit-1.0.0/src/pylab/data/students.csv +7 -0
- python_lab_toolkit-1.0.0/src/pylab/data/winequality-red.csv +1601 -0
- python_lab_toolkit-1.0.0/src/pylab/data/winequality-white.csv +2401 -0
- python_lab_toolkit-1.0.0/src/pylab/datasets.py +277 -0
- python_lab_toolkit-1.0.0/src/pylab/environment.py +136 -0
- python_lab_toolkit-1.0.0/src/pylab/errors.py +53 -0
- python_lab_toolkit-1.0.0/src/pylab/generator.py +216 -0
- python_lab_toolkit-1.0.0/src/pylab/registry.py +562 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q1/variable_validator.py +43 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q10/password_strength.py +42 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q11/recursion_math.py +28 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q12/main_analyzer.py +46 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q12/text_analyzer.py +16 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q12/text_preprocessor.py +15 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q13/student.py +26 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q14/circle.py +26 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q15/employee_salary.py +46 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q16/smart_calculator.py +51 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q17/complex_number.py +43 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q18/vehicle_inheritance.py +43 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q19/file_word_counter.py +48 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q19/sample.txt +6 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q2/single_number.py +26 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q20/age_validator.py +27 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q21/transaction_manager.py +45 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q22/date_formatter.py +30 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q23/rainfall_analyzer.py +73 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q24/student_marks.py +58 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q25/library_manager.py +182 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q26/mysql_employee_manager.py +239 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q27/crud_client.py +98 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q27/mock_server.py +85 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q28/index.html +33 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q28/login_handler.py +31 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q28/server.py +44 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q29/index.html +50 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q29/register_handler.py +42 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q29/server.py +42 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q3/string_operations.py +32 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q30/crud_handler.py +60 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q30/database.py +66 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q30/index.html +59 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q30/server.py +51 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q31/numpy_matrix.py +40 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q32/numpy_slicing.py +43 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q33/pandas_students.py +41 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q34/pandas_salary.py +37 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q35/sales_barchart.py +58 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q36/weather_plot.py +50 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q37/age_categorization.py +38 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q38/concat_rows.py +38 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q39/concat_cols.py +38 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q4/menu_string_processor.py +68 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q40/concat_merge.py +44 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q41/pandas_joins.py +46 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q42/groupby_school.py +32 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q43/groupby_multi.py +29 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q44/alphabet_stock_viz.py +95 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q45/multi_plot.py +65 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q46/dataframe_barchart.py +60 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q47/preprocess_data.py +54 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q48/clean_dirtydata.py +62 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q49/wine_regression.py +169 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q5/phonebook.py +105 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q50/breast_cancer_classifier.py +147 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q51/iris_clustering.py +95 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q52/apriori_groceries.py +88 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q6/calculator.py +67 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q7/session_attendees.py +37 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q8/number_properties.py +68 -0
- python_lab_toolkit-1.0.0/src/pylab/templates/q9/greet_people.py +26 -0
- python_lab_toolkit-1.0.0/src/python_lab_toolkit.egg-info/PKG-INFO +427 -0
- python_lab_toolkit-1.0.0/src/python_lab_toolkit.egg-info/SOURCES.txt +96 -0
- python_lab_toolkit-1.0.0/src/python_lab_toolkit.egg-info/dependency_links.txt +1 -0
- python_lab_toolkit-1.0.0/src/python_lab_toolkit.egg-info/entry_points.txt +2 -0
- python_lab_toolkit-1.0.0/src/python_lab_toolkit.egg-info/requires.txt +16 -0
- python_lab_toolkit-1.0.0/src/python_lab_toolkit.egg-info/top_level.txt +1 -0
- python_lab_toolkit-1.0.0/tests/test_cli.py +75 -0
- python_lab_toolkit-1.0.0/tests/test_database_and_cgi.py +98 -0
- python_lab_toolkit-1.0.0/tests/test_datasets.py +80 -0
- python_lab_toolkit-1.0.0/tests/test_execution.py +177 -0
- python_lab_toolkit-1.0.0/tests/test_generator.py +85 -0
- python_lab_toolkit-1.0.0/tests/test_registry.py +66 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Python Lab Toolkit Developers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: python-lab-toolkit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A beginner-friendly CLI and toolkit to generate 52 complete Python lab solutions with automated dataset management.
|
|
5
|
+
Author-email: Python Lab Toolkit Developers <dev@pylabtoolkit.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pylabtoolkit/python-lab-toolkit
|
|
8
|
+
Project-URL: Documentation, https://github.com/pylabtoolkit/python-lab-toolkit#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/pylabtoolkit/python-lab-toolkit.git
|
|
10
|
+
Project-URL: Issues, https://github.com/pylabtoolkit/python-lab-toolkit/issues
|
|
11
|
+
Keywords: education,python-lab,code-generator,data-science,cli
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Topic :: Education
|
|
23
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
29
|
+
Provides-Extra: requests
|
|
30
|
+
Requires-Dist: requests>=2.25.0; extra == "requests"
|
|
31
|
+
Provides-Extra: labs
|
|
32
|
+
Requires-Dist: requests>=2.25.0; extra == "labs"
|
|
33
|
+
Requires-Dist: numpy>=1.20.0; extra == "labs"
|
|
34
|
+
Requires-Dist: pandas>=1.3.0; extra == "labs"
|
|
35
|
+
Requires-Dist: matplotlib>=3.4.0; extra == "labs"
|
|
36
|
+
Requires-Dist: seaborn>=0.11.0; extra == "labs"
|
|
37
|
+
Requires-Dist: scikit-learn>=1.0.0; extra == "labs"
|
|
38
|
+
Requires-Dist: mlxtend>=0.19.0; extra == "labs"
|
|
39
|
+
Requires-Dist: mysql-connector-python>=8.0.0; extra == "labs"
|
|
40
|
+
|
|
41
|
+
# Python Lab Toolkit (`python-lab-toolkit`)
|
|
42
|
+
|
|
43
|
+
[](https://pypi.org/project/python-lab-toolkit/)
|
|
44
|
+
[](https://www.python.org/)
|
|
45
|
+
[](LICENSE)
|
|
46
|
+
[]()
|
|
47
|
+
[]()
|
|
48
|
+
|
|
49
|
+
A beginner-friendly, production-quality Python package and CLI named `pylab` designed to generate complete, working, runnable solutions for all **52 Python laboratory questions** with automatic dataset downloading and verified offline support.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Table of Contents
|
|
54
|
+
1. [Key Features](#key-features)
|
|
55
|
+
2. [Installation](#installation)
|
|
56
|
+
3. [Quick Start](#quick-start)
|
|
57
|
+
4. [Complete Command Reference](#complete-command-reference)
|
|
58
|
+
5. [The 52 Lab Questions Catalog](#the-52-lab-questions-catalog)
|
|
59
|
+
6. [Automated Dataset Management](#automated-dataset-management)
|
|
60
|
+
7. [Offline Installation & Laboratory Bundle](#offline-installation--laboratory-bundle)
|
|
61
|
+
8. [Database Configuration (SQLite & MySQL)](#database-configuration-sqlite--mysql)
|
|
62
|
+
9. [CGI Web Handlers and Local Test Servers](#cgi-web-handlers-and-local-test-servers)
|
|
63
|
+
10. [Troubleshooting & FAQ](#troubleshooting--faq)
|
|
64
|
+
11. [Development & Automated Testing](#development--automated-testing)
|
|
65
|
+
12. [PyPI Publication Guide](#pypi-publication-guide)
|
|
66
|
+
13. [License & Dataset Attribution](#license--dataset-attribution)
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 1. Key Features
|
|
71
|
+
|
|
72
|
+
- **Short, Intuitive Commands**: Generate any project with simple commands like `pylab q1`, `pylab q12`, `pylab q49`.
|
|
73
|
+
- **Zero Comments in Generated Code**: In accordance with clean code standards, generated Python source code contains **no explanatory inline comments, decorative comments, or header comments**, remaining self-explanatory through readable structure and expressive naming.
|
|
74
|
+
- **Real, Runnable Python Files**: Generates real files on disk (not hidden functions or stubs) that students and instructors can inspect, run, and modify.
|
|
75
|
+
- **Automated Dataset Handling**: Automatically downloads datasets when missing or instantly extracts verified bundled datasets when offline.
|
|
76
|
+
- **100% Offline Capable**: Small verified copies of all required datasets (`winequality-red.csv`, `iris.csv`, `breast-cancer.csv`, `groceries.csv`, `Data.csv`, `dirtydata.csv`, `alphabet_stock_data.csv`, `rainfall.csv`, `students.csv`) are bundled inside the package wheel.
|
|
77
|
+
- **Zero External Dependencies for Generator**: The `pylab` CLI and generator depend strictly on the Python standard library. It installs anywhere instantly without dependency conflicts.
|
|
78
|
+
- **Accidental Overwrite Protection**: Existing user files are never silently overwritten. Use `--force` to deliberately replace files.
|
|
79
|
+
- **Built-in System Doctor**: Run `pylab doctor` to check Python versions, directory permissions, and optional scientific libraries.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 2. Installation
|
|
84
|
+
|
|
85
|
+
### Standard Installation via pip
|
|
86
|
+
```bash
|
|
87
|
+
python -m pip install python-lab-toolkit
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Optional Scientific Libraries
|
|
91
|
+
The core toolkit runs anywhere on standard Python. If you want to execute machine learning, plotting, or numerical labs (Q23, Q31-Q52), install the scientific packages:
|
|
92
|
+
```bash
|
|
93
|
+
python -m pip install -r requirements-labs.txt
|
|
94
|
+
```
|
|
95
|
+
Or install specific dependencies per question:
|
|
96
|
+
```bash
|
|
97
|
+
pylab install-deps q49
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 3. Quick Start
|
|
103
|
+
|
|
104
|
+
### 1. View Available Questions
|
|
105
|
+
```bash
|
|
106
|
+
pylab list
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 2. Generate a Single Question
|
|
110
|
+
Generate the modular text analysis lab (Question 12):
|
|
111
|
+
```bash
|
|
112
|
+
pylab q12
|
|
113
|
+
```
|
|
114
|
+
Output:
|
|
115
|
+
```text
|
|
116
|
+
Question 12 generated successfully.
|
|
117
|
+
|
|
118
|
+
Project: q12_text_analysis/
|
|
119
|
+
|
|
120
|
+
Files:
|
|
121
|
+
text_preprocessor.py
|
|
122
|
+
text_analyzer.py
|
|
123
|
+
main_analyzer.py
|
|
124
|
+
README.md
|
|
125
|
+
|
|
126
|
+
Run:
|
|
127
|
+
python q12_text_analysis/main_analyzer.py
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 3. Run the Generated Program
|
|
131
|
+
```bash
|
|
132
|
+
python q12_text_analysis/main_analyzer.py
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 4. Generate Machine Learning Labs with Automatic Datasets
|
|
136
|
+
Generate the 22-step Wine Quality regression pipeline:
|
|
137
|
+
```bash
|
|
138
|
+
pylab q49
|
|
139
|
+
```
|
|
140
|
+
This automatically obtains `winequality-red.csv` and `winequality-white.csv`, creates `results/`, and generates `wine_regression.py` and `README.md`.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 4. Complete Command Reference
|
|
145
|
+
|
|
146
|
+
| Command | Description |
|
|
147
|
+
| :--- | :--- |
|
|
148
|
+
| `pylab list` | Display all 52 registered questions with numbers, titles, and categories. |
|
|
149
|
+
| `pylab list --category <cat>` | Filter questions by category (`fundamentals`, `oop`, `pandas`, etc.). |
|
|
150
|
+
| `pylab q<N>` | Generate Question `<N>` (e.g. `pylab q1`, `pylab q25`, `pylab q49`). |
|
|
151
|
+
| `pylab q<N> --force` | Overwrite existing project files. |
|
|
152
|
+
| `pylab q<N> --offline` | Force usage of bundled offline datasets. |
|
|
153
|
+
| `pylab q<N> --output-dir <dir>` | Generate the project inside a specified directory. |
|
|
154
|
+
| `pylab category <cat>` | Generate all questions belonging to a specific category. |
|
|
155
|
+
| `pylab all` | Generate all 52 questions (prompts for confirmation). |
|
|
156
|
+
| `pylab all --yes` | Generate all 52 questions non-interactively. |
|
|
157
|
+
| `pylab doctor` | Inspect environment, Python version, directory write permissions, and libraries. |
|
|
158
|
+
| `pylab datasets` | Display status and metadata for all bundled and downloadable datasets. |
|
|
159
|
+
| `pylab install-deps <q>` | Check and install missing optional pip packages for a specific question. |
|
|
160
|
+
| `pylab version` | Show the installed toolkit version. |
|
|
161
|
+
| `pylab --help` | Display CLI help and options. |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 5. The 52 Lab Questions Catalog
|
|
166
|
+
|
|
167
|
+
### Python Fundamentals (Questions 1–11)
|
|
168
|
+
- **Q1 (`q01_variable_name_validator`)**: Validate identifier rules and check reserved keywords using `keyword.iskeyword()`.
|
|
169
|
+
- **Q2 (`q02_single_number`)**: Find the unique integer in an array where all other integers appear twice using XOR ($O(n)$ time, $O(1)$ space).
|
|
170
|
+
- **Q3 (`q03_string_operations`)**: Implement `process_string()` to display uppercase, lowercase, length, slicing reversal `[::-1]`, and palindrome status.
|
|
171
|
+
- **Q4 (`q04_menu_string_processor`)**: Menu-driven program for substring checking, character occurrence counting, substring replacement, and uppercase conversion.
|
|
172
|
+
- **Q5 (`q05_phonebook`)**: Dictionary-based contact management supporting Add, Update, Search, Delete, and Display.
|
|
173
|
+
- **Q6 (`q06_simple_calculator`)**: Arithmetic calculator supporting `+`, `-`, `*`, `/`, `//`, `%`, `**` with zero-division handling.
|
|
174
|
+
- **Q7 (`q07_session_attendees`)**: Set operations on conference attendees: Union, Intersection, AI-only, and Cybersecurity-only.
|
|
175
|
+
- **Q8 (`q08_number_properties`)**: Functions verifying Even/Odd, Palindrome, Armstrong numbers, Prime numbers, and Perfect numbers.
|
|
176
|
+
- **Q9 (`q09_greet_people`)**: Variable argument function `greet_people(*names)` handling zero, one, or multiple parameters.
|
|
177
|
+
- **Q10 (`q10_password_strength`)**: Password validator testing length, digits, uppercase, lowercase, and special characters with detailed deficiency reporting.
|
|
178
|
+
- **Q11 (`q11_recursion`)**: Recursive sum and recursive factorial evaluated on $n = 5, 10, 18$.
|
|
179
|
+
|
|
180
|
+
### Modular Programming (Question 12)
|
|
181
|
+
- **Q12 (`q12_text_analysis`)**: Multi-module architecture with `text_preprocessor.py`, `text_analyzer.py`, and `main_analyzer.py` displaying required function docstrings via `__doc__`.
|
|
182
|
+
|
|
183
|
+
### Object-Oriented Programming (Questions 13–18)
|
|
184
|
+
- **Q13 (`q13_student_class`)**: `Student` class with `name`, `roll_number`, `course`, and `display()`.
|
|
185
|
+
- **Q14 (`q14_circle_class`)**: `Circle` class with radius, `area()`, and `circumference()` methods using `math.pi`.
|
|
186
|
+
- **Q15 (`q15_employee_salary`)**: `Employee` gross salary calculator with basic pay, HRA (20%), and DA (10%).
|
|
187
|
+
- **Q16 (`q16_smart_calculator`)**: `SmartCalculator` demonstrating default arguments, `*args` multiplication, and polymorphic type dispatch.
|
|
188
|
+
- **Q17 (`q17_complex_number`)**: `ComplexNumber` class with `+` (`__add__`) and `==` (`__eq__`) operator overloading.
|
|
189
|
+
- **Q18 (`q18_vehicle_inheritance`)**: `Vehicle` base class and `Car` derived class with method overriding and `super()`.
|
|
190
|
+
|
|
191
|
+
### Files, Exceptions, and Dates (Questions 19–22)
|
|
192
|
+
- **Q19 (`q19_file_word_counter`)**: Read text file, count lines, words, characters, find top 5 frequent words, and handle file exceptions. Includes `sample.txt`.
|
|
193
|
+
- **Q20 (`q20_custom_exception_age`)**: Custom exception `InvalidAgeException` validating ages between 18 and 60.
|
|
194
|
+
- **Q21 (`q21_transaction_handling`)**: Robust banking transaction demonstrating `try`, `except`, `else`, and `finally` blocks.
|
|
195
|
+
- **Q22 (`q22_date_formatter`)**: Date parser converting `dd-mm-yyyy` to `MonthName dd, yyyy` with invalid calendar date detection.
|
|
196
|
+
|
|
197
|
+
### CSV Processing (Questions 23–24)
|
|
198
|
+
- **Q23 (`q23_rainfall_analysis`)**: Read rainfall CSV data, calculate station averages, maximum rainfall record, standard deviation, and export results.
|
|
199
|
+
- **Q24 (`q24_students_csv`)**: Manage `students.csv`, find highest-scoring student, and compute class average marks.
|
|
200
|
+
|
|
201
|
+
### Database Systems (Questions 25–26)
|
|
202
|
+
- **Q25 (`q25_sqlite_library`)**: SQLite Library Management system with parameterized single inserts, `executemany()` batch inserts, category queries, and menu CLI.
|
|
203
|
+
- **Q26 (`q26_mysql_employee`)**: MySQL Employee Management system with parameterized queries, salary filtering (> ₹50,000), and secure environment credentials.
|
|
204
|
+
|
|
205
|
+
### REST API & Networking (Question 27)
|
|
206
|
+
- **Q27 (`q27_crudcrud_api`)**: Functional `requests`-based REST client performing Create, Read, Update, and Delete on students. Includes built-in `mock_server.py` for offline testing!
|
|
207
|
+
|
|
208
|
+
### CGI & Web Applications (Questions 28–30)
|
|
209
|
+
- **Q28 (`q28_cgi_login`)**: HTML login form and Python CGI handler displaying welcome response, with built-in `server.py`.
|
|
210
|
+
- **Q29 (`q29_cgi_registration`)**: MSc registration form and Python CGI script returning formatted admission receipt.
|
|
211
|
+
- **Q30 (`q30_cgi_crud`)**: Web-based database CRUD portal backed by SQLite, HTML frontend, and Python CGI HTTP server.
|
|
212
|
+
|
|
213
|
+
### NumPy and Pandas Numerical Analysis (Questions 31–43)
|
|
214
|
+
- **Q31 (`q31_numpy_matrix_operations`)**: Array 1–20 reshaped to 4×5, transpose, total/row/column sums, and even number extraction.
|
|
215
|
+
- **Q32 (`q32_numpy_slicing_reversal`)**: 5×5 array (1–25) submatrix slicing, row slicing, column slicing, and axis reversals.
|
|
216
|
+
- **Q33 (`q33_pandas_student_pass_fail`)**: Convert student marks Series to DataFrame, classify Pass/Fail, and filter passing students.
|
|
217
|
+
- **Q34 (`q34_pandas_employee_salary`)**: Departmental salary analysis computing average salary per department and top earner.
|
|
218
|
+
- **Q35 (`q35_pandas_sales_barchart`)**: 6 months sales table for 3 products, detecting top month, and plotting bar chart to `results/`.
|
|
219
|
+
- **Q36 (`q36_pandas_weather_plot`)**: 7-day weather table calculating average temperature and total rainfall, plotting temperature trend line.
|
|
220
|
+
- **Q37 (`q37_pandas_age_categorization`)**: Continuous age categorization using `pd.cut()` with mismatch detection.
|
|
221
|
+
- **Q38 (`q38_pandas_concat_rows`)**: Concatenate two student DataFrames along rows (`axis=0`).
|
|
222
|
+
- **Q39 (`q39_pandas_concat_cols`)**: Combine student DataFrames along columns (`axis=1`).
|
|
223
|
+
- **Q40 (`q40_pandas_concat_merge`)**: Concatenate student batches and merge with exam scores DataFrame on `student_id`.
|
|
224
|
+
- **Q41 (`q41_pandas_join_operations`)**: Relational join operations: Inner, Left, Right, and Outer joins with detailed semantics explanation.
|
|
225
|
+
- **Q42 (`q42_pandas_groupby_school`)**: Group school records by school code, compute mean/min/max age, and inspect GroupBy object type.
|
|
226
|
+
- **Q43 (`q43_pandas_groupby_multi`)**: Multi-column GroupBy (`['school_code', 'class']`) computing group counts with `size()`.
|
|
227
|
+
|
|
228
|
+
### Visualization and Preprocessing (Questions 44–48)
|
|
229
|
+
- **Q44 (`q44_alphabet_stock_visualization`)**: Alphabet stock historical data filtering, line plots, volume bar plot, stacked OHLC histogram, and scatter correlation.
|
|
230
|
+
- **Q45 (`q45_multi_plot_demonstration`)**: 2×2 multi-plot demonstration grid (waveform, categories, scatter, histogram).
|
|
231
|
+
- **Q46 (`q46_dataframe_barchart`)**: Grouped categorical bar plot with value annotations and legends.
|
|
232
|
+
- **Q47 (`q47_data_preprocessing`)**: Impute missing numerical values (`SimpleImputer`), One-Hot encode categorical features, and standard scale features (`StandardScaler`).
|
|
233
|
+
- **Q48 (`q48_dirtydata_cleaning`)**: Clean dirty dataset: fix inconsistent date formats, impute null calories, correct outlier duration, and drop duplicates.
|
|
234
|
+
|
|
235
|
+
### Machine Learning & Data Mining Pipelines (Questions 49–52)
|
|
236
|
+
- **Q49 (`q49_wine_quality_regression`)**: Full 22-step regression pipeline on red and white wine: data integration, correlation heatmap, feature scaling, Linear Regression, Decision Tree Regressor, Random Forest Regressor, and $R^2$, MAE, MSE, RMSE evaluation.
|
|
237
|
+
- **Q50 (`q50_breast_cancer_classification`)**: Breast cancer diagnosis classification, Random Forest feature ranking, top-feature reduction, and classifier comparison (Decision Tree, Random Forest, Logistic Regression) with confusion matrices and false-negative analysis.
|
|
238
|
+
- **Q51 (`q51_iris_clustering`)**: Unsupervised clustering on Iris features: standardization, K-Means ($k = 2, 3, 4$), elbow method, and 2D PCA cluster visualization.
|
|
239
|
+
- **Q52 (`q52_apriori_association_rules`)**: Market basket transaction processing with Apriori, frequent itemset generation, and association rules sorted by lift.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## 6. Automated Dataset Management
|
|
244
|
+
|
|
245
|
+
When generating questions requiring datasets, `pylab` automatically acquires them:
|
|
246
|
+
|
|
247
|
+
```text
|
|
248
|
+
q49_wine_quality_regression/
|
|
249
|
+
├── wine_regression.py
|
|
250
|
+
├── winequality-red.csv <-- Auto-acquired
|
|
251
|
+
├── winequality-white.csv <-- Auto-acquired
|
|
252
|
+
├── README.md
|
|
253
|
+
└── results/
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Dataset Registry
|
|
257
|
+
| Dataset Filename | Used In | Official Source | Bundled Offline |
|
|
258
|
+
| :--- | :--- | :--- | :--- |
|
|
259
|
+
| `winequality-red.csv` | Q49 | UCI Machine Learning Repository | Yes |
|
|
260
|
+
| `winequality-white.csv` | Q49 | UCI Machine Learning Repository | Yes |
|
|
261
|
+
| `breast-cancer.csv` | Q50 | UCI Machine Learning Repository | Yes |
|
|
262
|
+
| `iris.csv` | Q51 | UCI Machine Learning Repository | Yes |
|
|
263
|
+
| `groceries.csv` | Q52 | Association Mining Market Baskets | Yes |
|
|
264
|
+
| `Data.csv` | Q47 | ML Preprocessing Reference Data | Yes |
|
|
265
|
+
| `dirtydata.csv` | Q48 | Data Cleaning Reference Data | Yes |
|
|
266
|
+
| `alphabet_stock_data.csv` | Q44 | Financial Time Series Reference | Yes |
|
|
267
|
+
| `rainfall.csv` | Q23 | Weather Station Records | Yes |
|
|
268
|
+
| `students.csv` | Q24 | Student Grades Records | Yes |
|
|
269
|
+
|
|
270
|
+
To view dataset status at any time, run:
|
|
271
|
+
```bash
|
|
272
|
+
pylab datasets
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 7. Offline Installation & Laboratory Bundle
|
|
278
|
+
|
|
279
|
+
In lab environments where internet access is unavailable or restricted, you can prepare an offline installation bundle.
|
|
280
|
+
|
|
281
|
+
### Step 1: Prepare the Offline Wheels Folder (on an internet-connected machine)
|
|
282
|
+
```bash
|
|
283
|
+
mkdir -p offline_bundle/wheels
|
|
284
|
+
python -m pip download -d offline_bundle/wheels python-lab-toolkit
|
|
285
|
+
python -m pip download -d offline_bundle/wheels -r requirements-labs.txt
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Step 2: Install Completely Offline in the Laboratory
|
|
289
|
+
Transfer the `offline_bundle` folder to your offline laboratory computers and install:
|
|
290
|
+
```bash
|
|
291
|
+
python -m pip install --no-index --find-links ./offline_bundle/wheels python-lab-toolkit
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Step 3: Run Generation Offline
|
|
295
|
+
```bash
|
|
296
|
+
pylab q49 --offline
|
|
297
|
+
```
|
|
298
|
+
The toolkit will immediately use the verified bundled datasets stored inside the package wheel.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 8. Database Configuration (SQLite & MySQL)
|
|
303
|
+
|
|
304
|
+
### SQLite (Q25 & Q30)
|
|
305
|
+
SQLite is built into Python. No installation, server configuration, or credentials are required. The database files (`library.db` and `cgi_records.db`) are created automatically in the project folder.
|
|
306
|
+
|
|
307
|
+
### MySQL (Q26)
|
|
308
|
+
Question 26 integrates with a MySQL database.
|
|
309
|
+
To run Question 26 against your MySQL server:
|
|
310
|
+
1. Start your local MySQL service (e.g. `sudo systemctl start mysqld` or through XAMPP / MySQL Workbench).
|
|
311
|
+
2. Configure credentials using environment variables:
|
|
312
|
+
```bash
|
|
313
|
+
export MYSQL_HOST="localhost"
|
|
314
|
+
export MYSQL_USER="root"
|
|
315
|
+
export MYSQL_PASSWORD="your_password"
|
|
316
|
+
export MYSQL_DATABASE="company_db"
|
|
317
|
+
```
|
|
318
|
+
3. Run the manager:
|
|
319
|
+
```bash
|
|
320
|
+
python q26_mysql_employee/mysql_employee_manager.py
|
|
321
|
+
```
|
|
322
|
+
Or run the automated demonstration:
|
|
323
|
+
```bash
|
|
324
|
+
python q26_mysql_employee/mysql_employee_manager.py --demo
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## 9. CGI Web Handlers and Local Test Servers
|
|
330
|
+
|
|
331
|
+
Questions 28, 29, and 30 demonstrate CGI forms and web applications. Each generated project contains a self-contained local Python HTTP server (`server.py`).
|
|
332
|
+
|
|
333
|
+
To test in your browser:
|
|
334
|
+
```bash
|
|
335
|
+
cd q28_cgi_login
|
|
336
|
+
python server.py
|
|
337
|
+
```
|
|
338
|
+
Open `http://localhost:8080` in your web browser. You can enter credentials, submit forms, and inspect the CGI responses immediately!
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 10. Troubleshooting & FAQ
|
|
343
|
+
|
|
344
|
+
### "No module named 'numpy'" or other scientific library error
|
|
345
|
+
The code generator does not require scientific libraries, but running the generated script might. Run:
|
|
346
|
+
```bash
|
|
347
|
+
pylab install-deps <question_number>
|
|
348
|
+
# Example: pylab install-deps q49
|
|
349
|
+
```
|
|
350
|
+
Or install all lab dependencies at once:
|
|
351
|
+
```bash
|
|
352
|
+
pip install -r requirements-labs.txt
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### "The directory already contains existing files"
|
|
356
|
+
To prevent accidental loss of code, `pylab` will not overwrite existing directories. Pass `--force`:
|
|
357
|
+
```bash
|
|
358
|
+
pylab q12 --force
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### How can I check if my Python environment is ready?
|
|
362
|
+
Run the built-in system diagnostics tool:
|
|
363
|
+
```bash
|
|
364
|
+
pylab doctor
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## 11. Development & Automated Testing
|
|
370
|
+
|
|
371
|
+
### Running Tests
|
|
372
|
+
The toolkit includes a 56-test automated test suite verifying registry integrity, file generation, syntax correctness, comment absence (Rule A), CLI subcommands, database queries, and program execution.
|
|
373
|
+
|
|
374
|
+
Run the test suite using standard Python:
|
|
375
|
+
```bash
|
|
376
|
+
python -m unittest discover -s tests -v
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Building Distribution Packages
|
|
380
|
+
Build modern wheel and source distributions into `dist/`:
|
|
381
|
+
```bash
|
|
382
|
+
python setup.py sdist bdist_wheel
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## 12. PyPI Publication Guide
|
|
388
|
+
|
|
389
|
+
To publish `python-lab-toolkit` to PyPI:
|
|
390
|
+
|
|
391
|
+
### Step 1: Install Build and Twine Tools
|
|
392
|
+
```bash
|
|
393
|
+
python -m pip install --upgrade build twine
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Step 2: Build Clean Artifacts
|
|
397
|
+
```bash
|
|
398
|
+
rm -rf dist build src/*.egg-info
|
|
399
|
+
python -m build
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Step 3: Check Package Metadata with Twine
|
|
403
|
+
```bash
|
|
404
|
+
python -m twine check dist/*
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Step 4: Securely Upload to PyPI using an API Token
|
|
408
|
+
```bash
|
|
409
|
+
python -m twine upload --username __token__ dist/*
|
|
410
|
+
```
|
|
411
|
+
When prompted for your password, enter your PyPI API token (`pypi-AgEI...`).
|
|
412
|
+
|
|
413
|
+
> [!IMPORTANT]
|
|
414
|
+
> Never hardcode API tokens or passwords in configuration files or version control. Always use `__token__` and enter the secret token interactively or via the `TWINE_PASSWORD` environment variable.
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## 13. License & Dataset Attribution
|
|
419
|
+
|
|
420
|
+
### Package License
|
|
421
|
+
This software is distributed under the **MIT License**. See [LICENSE](LICENSE) for full details.
|
|
422
|
+
|
|
423
|
+
### Dataset Attributions
|
|
424
|
+
- **Wine Quality Datasets (`winequality-red.csv`, `winequality-white.csv`)**: P. Cortez, A. Cerdeira, F. Almeida, T. Matos, and J. Reis (2009). Modeling wine preferences by data mining from physicochemical properties. *Decision Support Systems*, Elsevier, 47(4):547-553.
|
|
425
|
+
- **Breast Cancer Wisconsin (Diagnostic) Dataset (`breast-cancer.csv`)**: Dr. William H. Wolberg, W. Nick Street, and Olvi L. Mangasarian. UCI Machine Learning Repository.
|
|
426
|
+
- **Iris Dataset (`iris.csv`)**: R.A. Fisher (1936). The use of multiple measurements in taxonomic problems. *Annals of Eugenics*, 7, Part II, 179-188.
|
|
427
|
+
- **Groceries Dataset (`groceries.csv`)**: Michael Hahsler, Kurt Hornik, and Christian Buchta (2005). arules - Mining Association Rules and Frequent Itemsets.
|