Python operators are the symbols that combine values into expressions: + to add, == to compare, and to join conditions, in to test membership. This chapter walks through every operator group in Python, from arithmetic to bitwise, and finishes with the precedence rules that decide which part of an expression runs first. Arithmetic operators The […]
Author: PK
Python Iterators and Generators: iter(), next() and yield
Python iterators and generators are the machinery behind every for loop. An iterator is an object that hands out one value at a time through next(). A generator is the easiest way to build one: a function that uses yield instead of return, producing values lazily so you can process millions of rows without loading […]
Python Data Types: str, int, float, bool, list and More
Python data types describe what kind of value a variable holds: text (str), whole numbers (int), decimals (float), true/false flags (bool), ordered collections (list, tuple), key-value pairs (dict) and unique items (set). Knowing the type tells you what operations are allowed. This chapter introduces each built-in type with a business example. The built-in data types […]
Python Functions: def, Arguments, Return and *args
A Python function is a named, reusable block of code that performs one task. You define it once with the def keyword, give it inputs called parameters, and call it as many times as you need. Functions return results with return, accept optional and keyword arguments, and can take any number of values through *args […]
Call an AI API from Python: OpenAI and Anthropic Examples
To call an AI API from Python you install the provider’s SDK, read your API key from an environment variable, and send a prompt to a model such as OpenAI’s GPT-5 or Anthropic’s Claude Sonnet 5. The reply comes back as a Python object you can print, parse as JSON or write into a report. […]
Python Math Module: Functions, Constants and Rounding
The Python math module gives you the functions a calculator has and a spreadsheet takes for granted: square roots, logarithms, ceiling and floor, factorials, constants such as pi and e, and precise summation. Combined with the built-in round() and the decimal module for money, it covers almost every number you will meet in business scripts. […]
Python Variables: Naming Rules, Assignment and Types
Python variables are named containers that hold a value, such as a price, a customer name or a list of invoices. You create a variable simply by assigning to it with =; there is no declaration step and no type keyword. This chapter covers how to name variables, how to assign them, how Python decides […]
Python Booleans: True, False and Truthy Values
Python booleans are the two values True and False. They are the answer to every yes-or-no question your program asks: is the invoice paid, is stock below the reorder level, does this list contain anything? Comparisons and conditions produce booleans, and Python also treats every other value as truthy or falsy, which this chapter explains. […]
Python with AI: Write Code with ChatGPT, Claude and Copilot
Python with AI means writing, fixing and understanding Python code together with an AI assistant such as ChatGPT, Claude or GitHub Copilot. You describe the task in plain language, the assistant drafts the code, and you run, test and refine it. Used well, it removes the blank-page problem and teaches you idioms faster than searching […]
Python Dates: datetime, strftime and Date Arithmetic
Python dates live in the built-in datetime module. It gives you date for a calendar day, datetime for a day plus time, timedelta for a duration, and strftime / strptime to convert between dates and text. Master those four and every due date, ageing report and month-end calculation becomes a few lines. Dates look simple […]









