Python comments are notes inside your code that Python ignores when it runs the program. A single-line comment starts with #, a multi-line comment is several # lines or a triple-quoted string, and a docstring is a special string that documents a function or module. Good comments explain why, not what. Single-line comments with # […]
Author: PK
Python in Excel: Use the PY Function for Data Analysis
Python in Excel lets you run Python code directly inside a Microsoft 365 worksheet cell with the =PY() function. The code executes in the Microsoft Cloud, reads your ranges and tables through xl(), and returns a value, a pandas DataFrame or a chart to the grid, so you can combine Excel formulas with pandas and […]
Python For Loops: range(), enumerate() and Nested Loops
A Python for loop walks through the items of a sequence one at a time and runs a block of code for each one. It works on lists, tuples, strings, dictionaries and anything else that is iterable. Combined with range(), enumerate() and zip(), the for loop is the workhorse of everyday data processing in Python. […]
Python String Formatting: f-strings and format() Examples
Python string formatting is how you insert values into text and control how they look: two decimal places, thousands separators, percentages, padding and alignment. Modern code uses f-strings, written with an f before the opening quote, while the older format() method is still common in templates and existing projects. This chapter covers both with business-style […]
Python Syntax: Indentation, Statements and Your First Program
Python syntax is the set of rules that decides how a Python program is written: one statement per line, indentation to group code blocks, a colon to open a block and no semicolons or braces. Because the rules are few, you can read most Python at first sight. This chapter covers each rule with a […]
Python Inheritance: Parent, Child Classes and super()
Python inheritance lets one class reuse the attributes and methods of another. The existing class is the parent (or base) class, the new one is the child (or derived) class. A child inherits everything from its parent, can add new behaviour and can override methods it wants to change, while super() calls the parent version […]
Python While Loops: break, continue and else
A Python while loop repeats a block of code for as long as a condition stays True. Python checks the condition before every pass, so the loop can run zero times, a few times or indefinitely. You control it with break, continue and an optional else clause that runs when the loop finishes normally. Basic […]
Install Python and Set Up VS Code with an AI Assistant
To install Python you download the official installer from python.org, tick one checkbox so the python command works everywhere, and then add Visual Studio Code with the Python extension as your editor. This chapter walks through both steps on Windows and Mac, runs your first script, and sets up an AI assistant next to your […]
Python Strings: Slicing, Methods and Escape Characters
Python strings are sequences of characters wrapped in single, double or triple quotes. You use them for names, invoice numbers, email addresses, file paths and every piece of text your program touches. In this chapter you will learn how to create Python strings, slice them, clean them with built-in methods and handle escape characters such […]
Python Modules and pip: Import, Install and Virtual Environments
Python modules and pip are how you stop writing everything yourself. A module is any .py file (or built-in library) whose functions you pull in with import; pip is the installer that downloads third-party packages from PyPI. Add a virtual environment and every project keeps its own clean set of packages. Up to now every […]









