Skip to main content
Engineering LibreTexts

15.5: Expressions and Statements

  • Page ID
  • An expression is a combination of values, variables, and operators. A value all by itself is considered an expression, and so is a variable, so the following are all legal expressions (assuming that the variable x has been assigned a value):

    x + 17

    A statement is a unit of code that the Python interpreter can execute. We have seen two kinds of statement: print and assignment.

    Technically an expression is also a statement, but it is probably simpler to think of them as different things. The important difference is that an expression has a value; a statement does not.

    • Was this article helpful?