Summary
We've looked at how we assign objects to variables. We've looked at the simple assignment statement, as well as multiple assignment and augmented assignment. With augmented assignment, we can update a variable by applying an operator and an operand. This is a handy syntactic shortcut.
We've also addressed the input()
function, which is a way to create new objects based on user input. It's very handy for simple command-line scripts. More sophisticated GUIs, of course, will have considerably more sophisticated input mechanisms.
The concept of a namespace, and how variables are tracked via a namespace, is central to Python. When a namespace is no longer needed, it's discarded, removing all of the variables. This will also reduce the reference count on all of the objects referred to by the variables. Once an object's reference count is reduced to zero, the object can be removed from memory. This is a tidy and simple way to handle variables.
In Chapter 5, Logic, Comparisons, and Conditions, we'll look at another fundamental data type: Boolean. We'll look at Python's approach to Boolean values and the logical operators of and
, or
, not
, and if-else
. We'll also look at the various comparison operators.
We'll look at several kinds of Python statements, include the if-elif-else
statement, the pass
statement, and the assert
statement. This will allow us to write somewhat more sophisticated scripts.