A comprehensive Python learning repository covering everything from fundamentals to advanced patterns, concurrency, cryptography, databases, and interview preparation. Each section contains standalone, runnable examples designed for learning and reference.
# Clone the repository
git clone https://github.com/hassonor/core-python.git
cd core-python
# (Optional) Create a virtual environment
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
# Install dependencies (not all are needed — see requirements.txt for details)
pip install -r requirements.txtNavigate to any topic directory and run examples directly:
python basic_knowledge/classes/airtravel.py- Core Python Basics
- Classes and Object-Oriented Programming
- Functions and Functional Programming
- Organizing Larger Programs
- Robust Resource and Error Handling
- Advanced Python
- Async I/O
- Parallel and Concurrent Programming
- Cryptography (PyCryptodome)
- Book Notes
- PyTorch Playground
- LeetCode Solutions
- Knowledge and Interview Prep
- Environment Setup
Foundational Python concepts and built-in data structures.
- Built-in Collections — Dictionaries, Lists, Sets, Strings, Tuples
- Binary Data — Working with binary data and bytes
- Classes — OOP fundamentals, flight booking system example
- Exceptions — Exception handling basics
- File I/O and Resource Management — Reading, writing, and managing files
- Iteration and Iterables — Iterators, generators, iteration protocols
- Other Fundamentals — Additional core concepts
Deep dive into Python's object model, inheritance, and OOP patterns.
- Class Attributes, Methods, and Properties — Shipping domain example
- Class Decorators — Decorator factories, location demo
- Multiple Inheritance and MRO
- String Representation of Objects —
__repr__,__str__,__format__
Closures, decorators, comprehensions, and functional programming paradigms.
- Closures — Lexical scoping and closure patterns
- Comprehensions — List, dict, set, and generator comprehensions
- Decorators — Decorator mechanics, parameterized decorators
- Extended Argument and Call Syntax —
*args,**kwargs, unpacking - Functional Programming —
map,filter,reduce, lambdas - Functions and Callables — Callable objects, first-class functions
Structuring Python projects with packages, modules, and plugins.
- Implementing Plugins — Plugin architecture patterns
- Namespace and Executable Packages — Namespace packages,
__main__.py - Nesting Modules with Packages — Package hierarchies
- Recommended Package Layout — Standard project structure
Exception handling, context managers, assertions, and debugging.
- Assertions
- Context Managers
- Exception Chaining — Implicit and explicit chaining
- Exception Payloads
- Tracebacks
Advanced language features, data handling, and database integration.
- Built-in Data Functions — Filtering, sorting, min/max, transforms
- Collection Classes — Counter, defaultdict, deque, namedtuple
- Python Logging — Basic and custom logging
- Serialization — JSON, CSV serialization/deserialization
- SQLite in Python
- MySQL in Python
- PostgreSQL in Python
- SQLAlchemy Workspaces — MySQL, PostgreSQL, and SQLite with SQLAlchemy (includes Docker Compose setups)
Asynchronous programming with asyncio and aiohttp.
- Asyncio Demos —
async/await,asyncio.gather, async iterators, sync-to-async conversion - Async Stock Fetcher — Real-world async HTTP example with
aiohttp
Threading, multiprocessing, synchronization, and concurrency pitfalls.
- Threads and Processes — Thread creation, daemon threads, process spawning
- Locks — Mutex locks, reentrant locks
- Mutual Exclusion — Data races, critical sections
- Liveness — Deadlock, livelock, starvation, abandoned locks
Practical cryptography examples using the PyCryptodome library.
- RSA — Key generation, encryption, decryption
- AES-CBC — AES encryption in CBC mode
- AES-EAX — AES authenticated encryption
- Hybrid RSA + AES — Combining asymmetric and symmetric encryption
- End-to-End Encryption — Full E2E encrypted client-server communication
Study notes and code examples from Python books.
- Chapter 1 — The Python Data Model (
FrenchDeck, special methods) - Chapter 2 — An Array of Sequences (list comprehensions,
Vectorclass)
Machine learning experiments with PyTorch and Jupyter notebooks.
- PyTorch Playground — Fashion MNIST, data exploration, neural network experiments
42 solutions organized by difficulty. Each includes problem description, approach, complexity analysis, and tests. Full list.
| # | Problem | Approach |
|---|---|---|
| 1 | Two Sum | Hash map |
| 9 | Palindrome Number | Math |
| 20 | Valid Parentheses | Stack |
| 35 | Search Insert Position | Binary search |
| 53 | Maximum Subarray | Kadane's algorithm |
| 67 | Add Binary | Math |
| 70 | Climbing Stairs | Dynamic programming |
| 83 | Remove Duplicates from Sorted List | Linked list |
| 88 | Merge Sorted Array | Two pointers |
| 118 | Pascal's Triangle | Dynamic programming |
| 121 | Best Time to Buy and Sell Stock | One pass |
| 136 | Single Number | XOR |
| 141 | Linked List Cycle | Floyd's tortoise & hare |
| 169 | Majority Element | Boyer-Moore voting |
| 206 | Reverse Linked List | Iterative pointers |
| 226 | Invert Binary Tree | Recursion |
| 242 | Valid Anagram | Character counting |
...and more easy problems
| # | Problem | Approach |
|---|---|---|
| 3 | Longest Substring Without Repeating Characters | Sliding window |
| 11 | Container With Most Water | Two pointers |
| 15 | 3Sum | Sort + two pointers |
| 33 | Search in Rotated Sorted Array | Modified binary search |
| 36 | Valid Sudoku | Hash sets |
| 49 | Group Anagrams | Sorted key hash map |
| 56 | Merge Intervals | Sort + merge |
| 102 | Binary Tree Level Order Traversal | BFS |
| 152 | Maximum Product Subarray | Track min/max |
| 200 | Number of Islands | DFS flood fill |
| 238 | Product of Array Except Self | Prefix/suffix products |
| # | Problem | Approach |
|---|---|---|
| 23 | Merge k Sorted Lists | Min-heap |
| 42 | Trapping Rain Water | Two pointers |
| 76 | Minimum Window Substring | Sliding window |
| 124 | Binary Tree Maximum Path Sum | DFS |
| 295 | Find Median from Data Stream | Two heaps |
Interview questions, algorithms, and practical Python knowledge.
- Algorithms — Algorithm implementations
- Arrays — Array-based interview questions
- Strings — String manipulation problems
- Defensive Programming — Security, sockets, SSL, vulnerability awareness
- Flask — Flask web framework project
- Other Topics — Miscellaneous Python knowledge
- Environment Setup Guide — Python installation and environment configuration
core-python/
├── advanced_python/ # Advanced features, databases, serialization
├── async_io_lib/ # Async/await, asyncio, aiohttp
├── basic_knowledge/ # Python fundamentals
├── book_notes/ # Book study notes (Fluent Python)
├── classes_and_oo/ # Object-oriented programming
├── functions_and_functional_programming/ # Closures, decorators, FP
├── install_steps/ # Environment setup guides
├── knowledge/ # Interview prep, algorithms, LeetCode
├── organizing_larger_programs/ # Packages, modules, plugins
├── parallel_and_concurrent/ # Threading, multiprocessing, locks
├── pycryptodome/ # Cryptography (RSA, AES)
├── pytorch_playground/ # PyTorch experiments
├── robust_resource_and_error_handling/ # Error handling, context managers
├── .cursorrules # AI coding assistant rules
├── .editorconfig # Editor configuration
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
├── LICENSE # MIT License
└── README.md # This file
Contributions, suggestions, and feedback are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-topic) - Commit your changes (
git commit -m 'Add new topic examples') - Push to the branch (
git push origin feature/new-topic) - Open a Pull Request
This project is licensed under the MIT License — see the LICENSE file for details.
Made with passion by hassonor