110+ Python scripts | 49 tutorials | 21 topic modules | From beginner to advanced
Learn Python through practical, well-documented, and runnable code examples.
Get Started Β· Topics Β· Contribute
- π Runnable examples β Every
.pyfile runs standalone with demo output - π Well-documented β Detailed comments, docstrings, and markdown tutorials
- π Progressive difficulty β From basics to production-grade patterns
- π¬ Real-world patterns β ETL pipelines, caching, config layering, and more
- π§© Modular β Each topic is self-contained, learn in any order
# Clone the repository
git clone https://github.com/rampal-punia/python-day-to-day.git
cd python-day-to-day
# Run any script directly
python functions/decorators_deep_dive.py
python generators/06_advanced_generators.py
python beginners_projects/tic_tac_toe.pyRequires Python 3.10+ for match/case examples. Most other files work with Python 3.8+.
| Topic | Files | Highlights |
|---|---|---|
| conditions/ | 2 | Ternary, chained comparisons, walrus :=, match/case (3.10+), guard clauses |
| strings/ | 9 | f-string mastery, all string methods, regex patterns, slicing, palindromes |
| numbers/ | 5 | Number formatting, prime number algorithms (4 approaches) |
| lists/ | 9 | Comprehensions, slicing, sorting, bisect, copy patterns, stack/queue, zip |
| tuple/ | 4 | Immutability, unpacking, namedtuple, tuple-as-dict-key, performance comparison |
| dictionary/ | 5 | Comprehensions, merging (|), defaultdict, nested dicts, grouping/aggregation |
| sets/ | 16 | Every set method documented β union, intersection, difference, subset, superset |
| Topic | Files | Highlights |
|---|---|---|
| functions/ | 15 | Decorators deep dive, *args/**kwargs, closures & LEGB scope, functools, lambda/map/filter/reduce |
| generators/ | 8 | Lazy evaluation, pipelining, yield from, send(), ETL pipeline, itertools |
| collections_module/ | 6 | deque (BFS, sliding window), defaultdict, Counter, ChainMap, performance benchmarks |
| datetime/ | 7 | Timezones (zoneinfo), timedelta, parsing/formatting, calendar, countdown timer |
| dataclasses/ | 3 | Tutorial, field(), __post_init__, dataclass vs class comparison |
| named_tuple/ | 3 | Tutorials, alternate constructors, comparison with dataclasses |
| Topic | Files | Highlights |
|---|---|---|
| beginners_projects/ | 10 | Tic-Tac-Toe (with AI), password checker/generator, todo manager, RPS, dice, FizzBuzz |
| operations_on_images/ | 8 | Resize, rotate, grayscale, thumbnail, format conversion (OpenCV + PIL) |
| pathlib_organise_files_project/ | 4 | File organizer project, pathlib tutorial, sample files for practice |
| logging/ | 1 | Loggers, handlers, formatters, console + file logging |
| misc/ | 10 | asyncio, colorama, object sizes, Python easter eggs, keywords |
| Topic | Files | Highlights |
|---|---|---|
| python_FAQs/ | 12 | __name__, deep vs shallow copy, truthy/falsy, polymorphism, parameters vs arguments |
| python_quizzes/ | 19 | "What's the output?" challenges β test your Python knowledge |
| random_module/ | 3 | random.choice, RGB generation, sampling |
python-day-to-day/
β
βββ π’ FUNDAMENTALS
β βββ conditions/ # if/elif, match/case, walrus operator
β βββ strings/ # formatting, methods, regex, slicing
β βββ numbers/ # formatting, prime algorithms
β βββ lists/ # comprehensions, slicing, sorting, bisect
β βββ tuple/ # immutability, unpacking, named tuples
β βββ dictionary/ # comprehensions, merging, nested access
β βββ sets/ # all set operations & methods
β
βββ π‘ INTERMEDIATE
β βββ functions/ # decorators, closures, functools, lambda
β βββ generators/ # lazy eval, pipelines, yield from, send()
β βββ collections_module/ # deque, defaultdict, Counter, ChainMap
β βββ datetime/ # timezones, timedelta, formatting
β βββ dataclasses/ # modern Python data containers
β βββ named_tuple/ # lightweight immutable objects
β
βββ π΄ PROJECTS & APPLIED
β βββ beginners_projects/ # games, tools, practical apps
β βββ operations_on_images/ # OpenCV & PIL image processing
β βββ pathlib_organise_files_project/ # file organizer
β βββ logging/ # production logging patterns
β βββ misc/ # asyncio, colorama, curiosities
β
βββ π REFERENCE
βββ python_FAQs/ # frequently asked questions
βββ python_quizzes/ # test your knowledge
βββ random_module/ # random number generation
# functions/decorators_deep_dive.py β 8 decorator patterns
@retry(max_attempts=3, delay=0.5)
def unreliable_api_call():
"""Auto-retry on failure β a real production pattern."""
...
@timer
def compute_sum(n: int) -> int:
"""Measure execution time automatically."""
return sum(range(n))# generators/06_advanced_generators.py
pipeline = add_tax(
filter_valid(
normalize(
parse_records(raw_data) # Each stage processes lazily
)
)
)
# Memory-efficient: processes 1 record at a time, not all at once!# conditions/conditions_complete_guide.py
def process_event(event: dict):
match event:
case {"type": "click", "x": x, "y": y}:
return f"Click at ({x}, {y})"
case {"type": "keypress", "key": key}:
return f"Key pressed: {key}"# collections_module/collections_deep_dive.py
recent_logs = deque(maxlen=100) # Auto-drops oldest when full
recent_logs.append(new_log) # Always O(1), never exceeds 100Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-topic) - Add well-documented, runnable Python files
- Submit a pull request
- Every
.pyfile should be runnable standalone withif __name__ == "__main__" - Include clear comments and docstrings
- Add practical examples, not just theory
- Follow the existing file structure and naming conventions
I share Python tips, code snippets, and learning resources regularly:
- π (Twitter): @rs_punia_