Skip to Content
Learning Python, 6th Edition
book

Learning Python, 6th Edition

by Mark Lutz
February 2025
Intermediate to advanced
1172 pages
42h 20m
English
O'Reilly Media, Inc.
Book available
Content preview from Learning Python, 6th Edition

Chapter 10. Introducing Python Statements

Now that you’re familiar with Python’s built-in objects, this chapter begins our exploration of its fundamental statement forms. Much like the previous part’s approach, we’ll begin here with a general introduction to statement syntax and follow up with more details about specific statements in the next few chapters.

In simple terms, statements are the code we write to tell Python what our programs should do. If, as suggested in Chapter 4, programs “do things with stuff,” then statements are the way we specify what sort of things a program does. Less informally, Python is a procedural, statement-based language; by combining statements, we specify a procedure that Python performs to satisfy a program’s goals.

The Python Conceptual Hierarchy Revisited

Another way to understand the role of statements is to revisit the concept hierarchy introduced in Chapter 4, which talked about built-in objects and the expressions used to manipulate them. This chapter climbs the hierarchy to the next level of Python program structure:

  1. Programs are composed of modules.

  2. Modules contain statements.

  3. Statements contain expressions.

  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 we studied in the preceding ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First Python, 3rd Edition

Head First Python, 3rd Edition

Paul Barry

Publisher Resources

ISBN: 9781098171292Errata PageSupplemental Content