mirror of
https://github.com/blshaer/python-by-example.git
synced 2026-03-27 23:29:25 +01:00
131 lines
4.3 KiB
Markdown
131 lines
4.3 KiB
Markdown
# Python Review - Complete Tutorial
|
|
|
|
A comprehensive Python tutorial covering everything from basics to advanced topics.
|
|
Each file is self-contained with detailed explanations and executable examples.
|
|
|
|
## 📚 Topics Covered
|
|
|
|
### 01. Basics
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_print.py` | Print function, formatting, escape characters |
|
|
| `02_comments.py` | Single-line, multi-line comments, docstrings |
|
|
| `03_variables.py` | Variable assignment, naming, multiple assignment |
|
|
| `04_data_types.py` | Numbers, strings, booleans, type conversion |
|
|
|
|
### 02. Control Flow
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_if_else.py` | Conditionals, comparison operators, logical operators |
|
|
| `02_elif.py` | Multiple conditions, grading systems, ranges |
|
|
| `03_match_case.py` | Pattern matching (Python 3.10+), guards, unpacking |
|
|
|
|
### 03. Loops
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_for_loop.py` | For loops, range(), enumerate(), zip() |
|
|
| `02_while_loop.py` | While loops, counters, sentinels, infinite loops |
|
|
| `03_break_continue.py` | Loop control, break, continue, pass, for-else |
|
|
|
|
### 04. Data Structures
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_lists.py` | Lists, indexing, slicing, methods, comprehensions |
|
|
| `02_tuples.py` | Tuples, immutability, unpacking, named tuples |
|
|
| `03_sets.py` | Sets, operations, frozen sets, practical uses |
|
|
| `04_dictionaries.py` | Dictionaries, methods, nesting, comprehensions |
|
|
|
|
### 05. Functions
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_function_basics.py` | Defining functions, scope, docstrings, nested functions |
|
|
| `02_arguments.py` | Positional, keyword, *args, **kwargs, type hints |
|
|
| `03_return_values.py` | Returns, multiple returns, early returns, generators |
|
|
| `04_lambda_functions.py` | Lambda, map, filter, reduce, functional patterns |
|
|
|
|
### 06. Modules & Packages
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_imports.py` | Import patterns, standard library, module organization |
|
|
| `02_custom_modules.py` | Creating modules, packages, __init__.py, __name__ |
|
|
|
|
### 07. Error Handling
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_try_except.py` | try/except/else/finally, catching exceptions |
|
|
| `02_custom_exceptions.py` | Creating exceptions, hierarchy, best practices |
|
|
|
|
### 08. Object-Oriented Programming
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_classes_objects.py` | Classes, objects, attributes, methods, self |
|
|
| `02_init_methods.py` | Constructors, properties, classmethods |
|
|
| `03_inheritance.py` | Single/multiple inheritance, super(), MRO, ABC |
|
|
| `04_polymorphism.py` | Duck typing, operator overloading, protocols |
|
|
|
|
### 09. Advanced Python
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_list_comprehensions.py` | List, dict, set comprehensions, generators |
|
|
| `02_generators.py` | Yield, iterators, memory efficiency, pipelines |
|
|
| `03_decorators.py` | Simple/parameterized decorators, functools |
|
|
| `04_context_managers.py` | with statement, __enter__/__exit__, contextlib |
|
|
|
|
### 10. Best Practices
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_pep8.py` | Python style guide, naming, formatting |
|
|
| `02_type_hinting.py` | Type annotations, typing module, generics |
|
|
| `03_virtual_envs.py` | venv, pip, requirements.txt, project setup |
|
|
|
|
## 🚀 How to Use
|
|
|
|
1. **Start from basics**: Begin with `01_basics` and work your way up
|
|
2. **Run the files**: Each file is executable: `python 01_print.py`
|
|
3. **Read the comments**: Each section is thoroughly explained
|
|
4. **Experiment**: Modify the code and observe the results
|
|
|
|
## 🛠️ Prerequisites
|
|
|
|
- Python 3.10+ recommended (for match/case support)
|
|
- Python 3.8+ minimum (for most features)
|
|
|
|
## 📝 File Structure
|
|
|
|
Each file follows this structure:
|
|
```python
|
|
"""
|
|
================================================================================
|
|
File: filename.py
|
|
Topic: Topic Name
|
|
================================================================================
|
|
|
|
Description of what the file covers...
|
|
|
|
Key Concepts:
|
|
- Concept 1
|
|
- Concept 2
|
|
- ...
|
|
|
|
================================================================================
|
|
"""
|
|
|
|
# Section 1: Basic Example
|
|
# ... code with inline comments ...
|
|
|
|
# Section 2: Advanced Example
|
|
# ... more code ...
|
|
```
|
|
|
|
## ✅ Learning Path
|
|
|
|
```
|
|
Beginner: 01_basics → 02_control_flow → 03_loops
|
|
Intermediate: 04_data_structures → 05_functions → 06_modules
|
|
Advanced: 07_error_handling → 08_oop → 09_advanced
|
|
Professional: 10_best_practices
|
|
```
|
|
|
|
---
|
|
*Happy Learning! 🐍*
|