Skip to Content
Skip to content
Tutorials

Programming Tutorials

Standalone programming tutorials for solving one specific problem at a time. Each guide starts with the exact error message, failing behavior, or design constraint, gives you a minimal reproducible script or query, and walks through the fix with real output.

Pick a language below or filter by topic and difficulty when you need a quick, practical reference you can test locally and apply right away.

Python
Python Closures: Building a Counter Without a Global Variable Level: Advanced

A closure remembers variables from the function that created it.

Python
Finding the Slow Part of Your Python Code With cProfile Level: Advanced

Don't guess which part is slow. Run cProfile, read cumtime and tottime the right way, fix the one line that matters, and measure again.

Python
Python dataclasses: A Class Without Writing __init__ by Hand Level: Intermediate

If a class mostly holds data, @dataclass writes __init__, a readable printout and equality for you.

Python
Fixing ModuleNotFoundError in Python, One Cause at a Time Level: Intermediate

ModuleNotFoundError has a handful of causes: the wrong Python, an inactive virtual environment, the wrong folder, or a file that shadows a module.

Python
Python Function Arguments: Defaults, Keywords and the Mutable Default Trap Level: Beginner

Defaults make functions easier to call and keywords make calls easier to read. A list as a default value is created once and shared by every call. Here's why, and the one-line fix.

Python
Python if, elif and else: Writing Conditions That Don't Overlap Level: Beginner

An if/elif chain stops at the first true condition. Put the widest one first and the others never run, with no error.

Python
Python if __name__ == "__main__": What It Does and When You Need It Level: Intermediate

Importing a file runs it. if __name__ == "__main__" keeps a file's script part from running when another file imports it.

Python
Python Is Not Recognized? Fixing PATH on Windows, Mac and Linux Level: Beginner

Python is probably installed. Your terminal just can't find it.

Python
Python Division and Rounding: /, //, % and round() Without Surprises Level: Beginner

/, //, % and round() each do exactly what they say, and that's not always what school math taught you.

Python
Python logging: Replacing print() Before It Gets Out of Hand Level: Intermediate

print() is for the output a person asked for. logging is for messages about the program: levels you can turn down, a file with times, and tracebacks for errors.