python-basics

Python fundamentals for beginners: variables, data types, operators, control flow, and functions, the core syntax every Python program is built on.

Python: Raising Exceptions & Custom Exception Classes

Learn to raise exceptions and create a Python custom exception in your own code. Build clear error names and tidy error families that make debugging easier, with tested examples and real-world patterns. “The best error message is the one that never shows up.” Thomas Fuchs Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Beginner | Reading Time: 16 minutes Python ships with built-in errors like ValueError and FileNotFoundError, and they cover the everyday stuff. But real apps ... Read More

Python: Higher-Order Functions, map(), filter(), reduce()

Transform a list, throw out the bad rows, total what is left: most data work is those three moves on repeat. The Python map filter reduce trio handles each move in a single line by taking your function as an argument. This post covers all three with tested examples, and is honest about when a plain list comprehension reads better. “A function that takes a function is just a recipe that takes another recipe as one of its ingredients.” Common ... Read More

Python: File Handling, Reading and Writing Text Files

Close a program and everything it computed vanishes with it: every variable, every user entry, gone. Python file handling is how a program remembers, by writing data to disk and reading it back on the next run. This guide covers reading, writing, and appending text files with the with statement, plus the mode and encoding choices that quietly decide whether your data survives. “Make it work, make it right, make it fast.” Kent Beck, TDD By Example Last Updated: July ... Read More