Skip to main content
[ "article:topic", "authorname:severancec", "python (language)", "jupyter:python", "license:ccbyncsa", "showtoc:no" ]
Engineering LibreTexts

2.4: Statements

  • Page ID
  • statement is a unit of code that the Python interpreter can execute. We have seen two kinds of statements: expression statement with "print" and assignment.


    When you type a statement in interactive mode, the interpreter executes it and displays the result, if there is one.

    A script usually contains a sequence of statements. If there is more than one statement, the results appear one at a time as the statements execute.

    For the script below, notice that the assignment statement (in this case x = 2) produces no output.

    Code \(\PageIndex{1}\) (Python):

    x = 2