- Notifications
You must be signed in to change notification settings - Fork18
A complete, folder-based guide to the Python language, from basics to advanced concepts, explained through clear, runnable code examples.
blshaer/python-by-example
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A practical, example-driven Python repository designed to help you learn Python from fundamentals to advanced concepts through clear, runnable code.
Each file is self-contained and focuses on a single concept, making the repository suitable for structured learning, revision, or reference.
Want to follow your progress? Visit the website atpythonbyexample.page.gd
If you like this project, please hit the ⭐ Star button and follow me on GitHub@blshaer!
This repository contains a complete Python tutorial designed for both beginners and experienced developers looking to refresh their knowledge. Each topic is organized in separate folders with practical, runnable examples.
Key Features:
- ✅Self-contained files — Each file can be run independently
- ✅Comprehensive comments — Detailed explanations for every concept
- ✅Practical examples — Real-world use cases and patterns
- ✅Progressive difficulty — From basics to advanced topics
| File | Topic | Description |
|---|---|---|
01_print.py | Print Function | Output, formatting, f-strings, escape characters |
02_comments.py | Comments | Single-line, multi-line, docstrings, best practices |
03_variables.py | Variables | Assignment, naming conventions, multiple assignment |
04_data_types.py | Data Types | Numbers, strings, booleans, type conversion |
| File | Topic | Description |
|---|---|---|
01_if_else.py | If/Else | Conditionals, comparison operators, logical operators |
02_elif.py | Elif | Multiple conditions, grading systems, ranges |
03_match_case.py | Match/Case | Pattern matching (Python 3.10+), guards, unpacking |
| File | Topic | Description |
|---|---|---|
01_for_loop.py | For Loops | Iteration, range(), enumerate(), zip() |
02_while_loop.py | While Loops | Counters, sentinels, infinite loops |
03_break_continue.py | Loop Control | break, continue, pass, for-else |
| File | Topic | Description |
|---|---|---|
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 |
| File | Topic | Description |
|---|---|---|
01_function_basics.py | Function Basics | Defining functions, scope, docstrings |
02_arguments.py | Arguments | Positional, keyword, *args, **kwargs, type hints |
03_return_values.py | Return Values | Multiple returns, early returns, generators |
04_lambda_functions.py | Lambda | Anonymous functions, map, filter, reduce |
| File | Topic | Description |
|---|---|---|
01_imports.py | Imports | Import patterns, standard library, organization |
02_custom_modules.py | Custom Modules | Creating modules, packages,__init__.py |
| File | Topic | Description |
|---|---|---|
01_try_except.py | Try/Except | Exception handling, else, finally |
02_custom_exceptions.py | Custom Exceptions | Creating exceptions, hierarchy, best practices |
| File | Topic | Description |
|---|---|---|
01_classes_objects.py | Classes & Objects | Attributes, methods, self |
02_init_methods.py | Init & Methods | Constructors, properties, classmethods |
03_inheritance.py | Inheritance | Single/multiple inheritance, super(), MRO |
04_polymorphism.py | Polymorphism | Duck typing, operator overloading, protocols |
| File | Topic | Description |
|---|---|---|
01_list_comprehensions.py | Comprehensions | List, dict, set comprehensions |
02_generators.py | Generators | Yield, iterators, memory efficiency |
03_decorators.py | Decorators | Simple/parameterized decorators, functools |
04_context_managers.py | Context Managers | with statement,__enter__/__exit__, contextlib |
| File | Topic | Description |
|---|---|---|
01_pep8.py | PEP 8 | Python style guide, naming, formatting |
02_type_hinting.py | Type Hinting | Type annotations, typing module, generics |
03_virtual_envs.py | Virtual Environments | venv, pip, requirements.txt |
Clone the repository
git clone https://github.com/blshaer/python_review.gitcd python_reviewStart from basics
cd 01_basicspython 01_print.pyRead the comments — Each section is thoroughly explained
Experiment — Modify the code and observe the results
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.10+ | Recommended (for match/case support) |
| Python | 3.8+ | Minimum (for most features) |
# Check your Python versionpython --versionEach Python file follows a consistent structure:
"""================================================================================File: filename.pyTopic: 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 ...
| 🌱 Beginner | 📈 Intermediate | 🚀 Advanced | 💼 Professional |
Recommended Flow:Beginner → 01_basics → 02_control_flow → 03_loopsIntermediate → 04_data_structures → 05_functions → 06_modulesAdvanced → 07_error_handling → 08_oop → 09_advancedProfessional → 10_best_practicesUse this checklist to track your learning progress:
- 01. Basics — Print, Comments, Variables, Data Types
- 02. Control Flow — If/Else, Elif, Match/Case
- 03. Loops — For, While, Break/Continue
- 04. Data Structures — Lists, Tuples, Sets, Dictionaries
- 05. Functions — Basics, Arguments, Returns, Lambda
- 06. Modules & Packages — Imports, Custom Modules
- 07. Error Handling — Try/Except, Custom Exceptions
- 08. OOP — Classes, Init, Inheritance, Polymorphism
- 09. Advanced Python — Comprehensions, Generators, Decorators
- 10. Best Practices — PEP8, Type Hints, Virtual Environments
Happy Learning!
Made with ❤️ byBaraa
About
A complete, folder-based guide to the Python language, from basics to advanced concepts, explained through clear, runnable code examples.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
