Chapter 4. Variables, Assignment and Scoping Rules

An expression creates objects; we can assign objects to variables to preserve them for future use. Python offers a number of variations on the theme of assignment. In addition to simply assigning a single variable, we can assign items from a tuple to multiple variables. We can also combine an operator with assignment, which updates a mutable object.

In this chapter, we'll also look at the input() function as a way to introduce new objects into a running script. This is limited—it doesn't compare with a proper graphical user interface (GUI). It will, however, help us learn more Python programming techniques before we introduce how to read data from files and the filesystem in Chapter 10, Files, ...

Get Python Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.