Skip to content

A collection of Python day-to-day codes that can help learning and understanding various use cases of Python.

Notifications You must be signed in to change notification settings

rampal-punia/python-day-to-day

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

243 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐍 Python Day-To-Day

A Curated Collection of Python Code Examples, Tutorials & Projects

Python License Contributions Welcome Twitter

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


✨ What Makes This Repo Special?

  • πŸƒ Runnable examples β€” Every .py file 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

πŸš€ Quick Start

# 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.py

Requires Python 3.10+ for match/case examples. Most other files work with Python 3.8+.


πŸ“š Topics at a Glance

🟒 Fundamentals

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

🟑 Intermediate

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

πŸ”΄ Applied & Projects

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

πŸ“ Reference & Learning

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

πŸ—‚οΈ Directory Structure

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

🌟 Featured Examples

Decorators β€” From Basics to Production Patterns

# 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 β€” ETL Pipeline

# 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!

Pattern Matching (Python 3.10+)

# 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 β€” Sliding Window with Deque

# 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 100

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-topic)
  3. Add well-documented, runnable Python files
  4. Submit a pull request

Contribution Guidelines

  • Every .py file should be runnable standalone with if __name__ == "__main__"
  • Include clear comments and docstrings
  • Add practical examples, not just theory
  • Follow the existing file structure and naming conventions

πŸ“¬ Connect

I share Python tips, code snippets, and learning resources regularly:


⭐ If you find this repository helpful, give it a star!

Learning Python is Fun. Keep Improving! πŸš€

About

A collection of Python day-to-day codes that can help learning and understanding various use cases of Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages