Python

91 articles in this topic

Context Managers in Python: with, __enter__, __exit__ and contextlib

Learn how Python's with statement guarantees cleanup, then build and trace class-based and generator-based context managers with runnable examples.

Updated 14 Oct 20266 min readPython

Python Arguments and Scope: Parameters, LEGB, and Worked Examples

Trace how Python binds arguments, handles mutation and rebinding, and resolves names through LEGB. Runnable examples turn scope rules into predictable output.

Updated 30 Oct 20265 min readPython

Python Control Flow and Loops: if, for, while and Worked Traces

Learn to trace Python branches and loops without skipping a state change. Worked examples cover GCD, break and continue, loop else, nested loops, and common mistakes.

Updated 30 Oct 20265 min readPython

Python for GATE: CS vs DA Syllabus, Past-Paper Evidence and a 10-Week Plan

Choose the right Python preparation path for GATE CS or DA, then use two worked traces and three diagnostic gates to test your progress.

Updated 30 Oct 20264 min read66 viewsPython

Python Modules and Packages Tutorial: Imports, Structure and Runnable Examples

Learn what Python imports bind, how a regular package fits together, and why package entry points should run with `python -m`. Build and trace every example yourself.

Updated 30 Oct 20266 min readPython

Pandas Basics in Python: Build, Clean and Analyse a DataFrame Step by Step

Follow one student dataset from its first DataFrame to a clean city summary, while learning how selection, missing values and vectorised calculations really work.

Updated 24 Sep 20265 min readPython

Python Operators and Expressions: Precedence, Types and Worked Output Traces

Trace Python expressions without guessing. This guide connects operator families, precedence, types, short-circuiting and exact output through worked examples.

Updated 23 Sep 20266 min readPython

CSV Files Explained: Parsing Rules, Worked Records and Exam Traps

Learn why commas and newlines are not always boundaries, trace a quote-aware parser, validate text fields with a schema, and calculate processing costs.

Updated 30 Oct 20265 min readPython

Polymorphism and Dunder Methods in Python: Runnable Examples and Exercises

See how one Python operation supports different types, then build a Vector2D class with readable output, addition, magnitude and equality. Includes runnable code, protocol failures and exercises.

Updated 21 Sep 20265 min readPython

Inheritance in Python: A Practical Tutorial with Examples

Learn how Python classes inherit state and behaviour through runnable examples. Trace super(), overrides, MRO, common mistakes, and three focused exercises.

Updated 19 Sep 20265 min read54 viewsPython

Python Generators and Iterators Tutorial: yield, next() and Lazy Evaluation

Build Python's iterator protocol from a three-value list, trace generators one request at a time, and practise safe one-pass pipelines with exact outputs.

Updated 18 Sep 20265 min read75 viewsPython

Introduction to Python: Core Concepts, Worked Trace and Exam Patterns

Build a reliable Python tracing method from names and types to loops and mutable lists. Follow one function across every iteration and check its exact output.

Updated 16 Sep 20266 min readPython