Languages
An interpreter is a translator that converts source code into machine code one line or statement at a time. Each line is executed immediately, then the interpreter moves on to the next one. It does not create an executable file, so the program is translated again every time it is run.
If an error occurs in a line, either while the line is being translated or while it runs, the interpreter stops at that line and displays an error message. You can see exactly where the problem is, which helps you find and fix it. Earlier lines have already been executed, so the program may have produced some output before it stops.
total = 8 + 4
print(total)
average = total / 0
print(average)Output:
12
ZeroDivisionError: division by zero (line 3)
Interpreters are most useful during development; compilers suit finished programs that are given to users.
OCR GCSE Computer Science · Languages