Index Ai Academy
Phase 0 · ToolsPython core

Your first program

About 15 min

Why this matters

Most of AI engineering, day to day, is a loop. Run some code, read what comes back, change something, run it again. That's true even when an AI assistant writes the code for you. You still have to run it, and make sense of the output and the errors. This lesson is that loop at its smallest.

  • Run Python code and show results with print()
  • Predict the order a program's lines run in
  • Use comments to leave notes Python ignores
  • Read an error message from the last line up and fix the cause

A program is a list of instructions

Think of a recipe. It's a list of steps, written in order, that someone follows exactly. A Python program is the same: plain text, with one instruction per line. When you run it, Python reads the instructions and carries them out.

The first instruction to learn is print(). It shows a value on the screen.

Press Run on the cell below. You can edit it and run it again as many times as you like.

print("Hello, world")
print("Index Ai Academy is running your code")

Two details matter here:

  • The parentheses after print hold the thing you want shown.
  • The quotes mark a piece of text. Programmers call text a string.

Without quotes, Python treats what you typed as code to work out:

print("2 + 3")
print(2 + 3)

The first line prints the characters 2 + 3 exactly as written. The second does the arithmetic and prints 5.

You can give print several things, separated by commas. It shows them all on one line, with a space between each:

print("Clicks this week:", 1200 + 340)
print("Emails sent:", 24000, "Opened:", 5280)