[Python] Basics - Statement

Posted by Wei's Blog on 2019-09-20, Last Modified on 2021-09-21

The Python Conceptual Hierarchy Revisited

A way to understand the role of statements is to revisit the concept hierarchy:

  1. Programs are composed of modules.

  2. Modules contain statements, e.g., a module contains a bunch of if statements.

  3. Statements contain expressions, e.g., a if statement contains a == expression.

  4. Expressions create and process objects.

At their base, programs written in the Python language are composed of statements and expressions. Expressions process objects and are embedded in statements. Statements code the larger logic of a program’s operation—they use and direct expressions to process the objects. Moreover, statements are where objects spring into existence (e.g., in expressions within assignment statements), and some statements create entirely new kinds of objects (functions, classes, and so on). At the top, statements always exist in modules, which themselves are managed with statements.

Reference

  • Python Crash Course (2nd Edition) : A Hands-On, Project-Based Introduction to Programming
  • Learning Python