Introduction to Python

This introduction to Python covers the parts of the language you’ll use every day once you start working with data and AI. Each lesson is short, focused on one idea and built around code you can run, with the output shown so you can check your own results.

It starts with enumerate(), the clean way to loop over a list when you also need each item’s position. Then comes error handling with try and except, so one bad value doesn’t stop a whole program. The next two lessons are about the formats data arrives in: JSON, the language of APIs and configuration files, and CSV, the format of every spreadsheet export. After that, object-oriented programming shows how to organize larger programs with classes, and gradient descent shows the idea at the heart of how machine learning models learn.

Follow the lessons in order if you’re new to Python, or pick the one you need. Every lesson ends with links to the previous and next one.

The lessons, in order

  1. How to Use enumerate() in PythonLoop over a list with each item's position, without keeping a counter by hand.
  2. Error Handling in Python: try and exceptCatch the errors you expect with try and except, so one bad value doesn't stop a program.
  3. How to Use JSON in PythonRead, write and convert JSON, the format of most APIs and configuration files.
  4. Mastering Python and CSV: A Guide for Data ManipulationRead and write CSV files with the csv module and pandas.
  5. Python Object Oriented Programming: A Comprehensive GuideOrganize larger programs with classes, objects and inheritance.
  6. Gradient Descent in Python – A Step-by-Step GuideCode gradient descent step by step and see how machine learning models learn.

Want to go further, one to one?

In Python AI mentoring we work on your own code: from these basics to an AI agent you have built and deployed yourself. Sessions start at $60 an hour, with a recording and notes after each one.