Agentic AI

Python core

Python from scratch: syntax, types, control flow, data structures, functions, modules, files and exceptions.

Python is the language almost every agentic AI tool is written in, and the one you will glue them together with. This module covers its core: values and types, text, decisions and loops, the four built-in collections, functions, modules, files and errors. Each lesson is a handful of small cells to run in a notebook, in order. Try each practice task before you open its solution.

Lessons

  1. 1Python syntax: comments, indentation and errorsCase sensitivity, comments, indentation, long lines, and the difference between a syntax error and a runtime error.
  2. 2Variables and data typesCreate variables, follow the naming rules, check types with type(), convert between int, float and str, and read input.
  3. 3Strings and f-stringsQuotes, indexing, len and in, the common string methods, split and join, and f-strings with format specs.
  4. 4OperatorsCalculate, compare and combine conditions: arithmetic, comparison and logical operators.
  5. 5Conditions: if, elif and elseRun different code depending on a condition, with nested checks and truthiness.
  6. 6Loops: for and whileRepeat code with for and while, and control a loop with break, continue and else.
  7. 7ListsKeep items in order, read them by position, slice them and change them with list methods.
  8. 8List comprehensionsBuild a new list from another in one readable line, with or without a filter.
  9. 9TuplesFixed sequences: create them, unpack them into variables and use them as records.
  10. 10SetsKeep unique items, test membership quickly and compare collections with set operations.
  11. 11DictionariesStore and look up values by key, loop over them, and copy them safely.
  12. 12FunctionsWrap code in reusable functions with parameters, defaults, *args, **kwargs and return values.
  13. 13Functions in practiceSmall, real functions to read and write: conversions, checks, totals and recursion.
  14. 14Lambda, map and filterPass small functions to map() and filter() to transform and select items.
  15. 15Modules and packagesImport code from the standard library, installed packages and your own files.
  16. 16The standard libraryThe built-in modules later lessons rely on: math, random, os, json, csv, datetime, time and re.
  17. 17Reading and writing filesRead and write text and binary files safely with open() and with.
  18. 18File pathsBuild and check file paths that work on every operating system.
  19. 19Handling exceptionsCatch errors with try and except, clean up with finally, and raise your own.