|
1 | 1 | # python-logic-lab |
2 | | -Mini python solutions |
3 | 2 |
|
4 | | -# 🐍 Python Logic Lab: Practical Scripts & Mini-Apps |
| 3 | +Mini python solutions |
5 | 4 |
|
6 | | -A collection of lightweight Python projects demonstrating core programming logic, |
7 | | -problem-solving, and automation. This repository showcases my ability to bridge |
| 5 | +# Python Logic Lab: Practical Scripts & Mini-Apps |
| 6 | + |
| 7 | +A collection of lightweight Python projects demonstrating core programming logic, |
| 8 | +problem-solving, and automation. This repository showcases my ability to bridge |
8 | 9 | technical code with real-world scenarios—from ATM simulations to data processing tools. |
9 | 10 |
|
10 | | -### 🚀 Featured Scripts |
11 | | -* **ATM Simulation:** A robust terminal-based app with transaction logging and error handling. |
12 | | -* **Network Port Scanner:** A multi-threaded utility that probes specific IP addresses for open ports. It demonstrates knowledge of the `socket` library, TCP handshakes, and network diagnostics—essential for technical SEO and web security audits. |
13 | | -* **Data Utility Tools:** Scripts designed to clean and prep data for Excel & Power BI. |
14 | | -* **AI & API Experiments:** Exploring rapid tech innovations through integrated Python libraries. |
| 11 | +### Featured Scripts |
| 12 | + |
| 13 | +- **ATM Simulation:** A robust terminal-based app with transaction logging and error handling. |
| 14 | + |
| 15 | +# ATM Mini Project |
| 16 | + |
| 17 | +Short description |
| 18 | + |
| 19 | +- Small CLI ATM simulator that supports withdrawals. |
| 20 | +- Core file: `atm_project.py`. Tests live in `test_atm.py`. |
| 21 | +- Designed for learning I/O, basic validation, logging and unit testing with mocks. |
| 22 | + |
| 23 | +Files |
| 24 | + |
| 25 | +- atm_project.py — main program and function `atm_withdrawal(balance)`: |
| 26 | + - Prompts user for an amount via input() |
| 27 | + - Validates numeric/positive/available funds |
| 28 | + - Prints result messages and returns the updated balance (float) |
| 29 | + - Logs transactions to `atm_transactions.log` |
| 30 | +- test_atm.py — unit tests that: |
| 31 | + - Mock `builtins.input` to simulate user input |
| 32 | + - Capture `sys.stdout` to assert printed messages |
| 33 | + - Assert returned balance values |
| 34 | + |
| 35 | +Requirements |
| 36 | + |
| 37 | +- Python 3.8+ |
| 38 | +- No external packages required |
| 39 | + |
| 40 | +How to run the program (Windows) |
| 41 | + |
| 42 | +- From project folder: |
| 43 | + - python atm_project.py |
| 44 | +- Interact via the menu; choose "1" to withdraw and follow prompts. |
| 45 | + |
| 46 | +How to run tests (Windows) |
15 | 47 |
|
16 | | -### 🛠️ Tech Stack |
17 | | -* **Language:** Python 3.12+ |
18 | | -* **Core Libraries:** `datetime`, `logging`, `math`, `sys`, `socket`, `threading` |
19 | | -* **Concepts:** Error Handling (Try/Except), File I/O, Data Validation, and Functional Programming. |
| 48 | +- From project folder: |
| 49 | + - python -m unittest c:\Users\sabia_kenya\Desktop\LearningPython_Basics\test_atm.py |
| 50 | + |
| 51 | +Notes about tests |
| 52 | + |
| 53 | +- Tests do not modify `atm_project.py`. They mock `input()` and capture stdout so the I/O code can be tested without changing the source. |
| 54 | +- Tests assert: |
| 55 | + - Correct updated balance returned by `atm_withdrawal` |
| 56 | + - Presence of expected printed messages (e.g., "Withdrawal successful", "Insufficient funds", "Invalid amount", and numeric-input error message) |
| 57 | + |
| 58 | +Suggestions for future improvements |
| 59 | + |
| 60 | +- Separate business logic from I/O: create functions like `process_withdrawal(balance, amount)` that only implement logic and return (new_balance, message). This simplifies testing (no mocking). |
| 61 | +- Add deposit functionality and persistence (file or DB) if desired. |
| 62 | +- Add a `reset_balance()` helper or class-based ATM to isolate state across tests. |
| 63 | + |
| 64 | +Logging |
| 65 | + |
| 66 | +- Transactions are appended to `atm_transactions.log` in the project directory with timestamps (configured in `atm_project.py`). |
20 | 67 |
|
21 | 68 | --- |
22 | | -*Building at the intersection of Data, Marketing, and Code.* |
| 69 | + |
| 70 | +- **Network Port Scanner:** A multi-threaded utility that probes specific IP addresses for open ports. It demonstrates knowledge of the `socket` library, TCP handshakes, and network diagnostics—essential for technical SEO and web security audits. |
| 71 | +- **Data Utility Tools:** Scripts designed to clean and prep data for Excel & Power BI. |
| 72 | +- **AI & API Experiments:** Exploring rapid tech innovations through integrated Python libraries. |
| 73 | + |
| 74 | +### Tech Stack |
| 75 | + |
| 76 | +- **Language:** Python 3.12+ |
| 77 | +- **Core Libraries:** `datetime`, `logging`, `math`, `sys`, `socket`, `threading`,`unittest`,`unittest.mock` ,`io` |
| 78 | +- **Concepts:** Error Handling (Try/Except), File I/O, Data Validation, and Functional Programming. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +_Building at the intersection of Data, Marketing, and Code._ |
0 commit comments