02 Interpreter
02 Interpreter
CSE 140
University of Washington
Michael Ernst
Two ways to run Python
• The Python interpreter
– You type one expression at a time
– The interpreter evaluates the expression and prints its
value
• Running a Python program
– Python evaluates all the statements in the file, in
order
– Python does not print their values (but does execute
print statements)
• Writing an expression outside a statement (assignment,
print, etc.) is useless, unless it is a function call that has a
side effect
The Python interpreter
The interpreter is a loop that does:
– Read an expression
– Evaluate the expression
– Print the result
If the result is None, the interpreter does not print it
This inconsistency can be confusing!