Introduction to Programming

Module 1 · Introduction to Programming · Lesson 6 of 7

What does an interpreter do?

Python runs through an interpreter. It works through your program one line at a time, and for each line it does three things: reads it, checks that it follows the rules, and runs it. Then it moves to the next line and repeats.

interpreter
name = "Ada"
print(name)
prnt("bye")
readcheckrun
Ada
NameError: 'prnt'

It stops at the first line it can't understand.

Because it goes line by line, the interpreter only discovers a problem when it actually reaches that line. Here the first two lines run fine — you see Ada printed — but the third has a typo (prnt instead of print). The interpreter stops there and reports the error.

Notice what that means: everything before the bad line already happened, and everything after it never runs. That line-by-line behaviour shapes how compiled and interpreted languages compare — which is the final lesson.