Chapter 2. Variables and Basic Types
In this chapter, we will present the most important and basic types in Python. What is a type? It is a set consisting of data content, its representation, and all possible operations. Later in this book, we will make this definition much more precise, when we introduce the concepts of a class in Chapter 8, Classes.
Variables
Variables are references to Python objects. They are created by assignments, for example:
a = 1 diameter = 3. height = 5. cylinder = [diameter, height] # reference to a list
Variables take names that consist of any combination of capital and small letters, the underscore _
, and digits. A variable name must not start with a digit. Note that variable names are case sensitive. A good naming of ...
Get Scientific Computing with Python 3 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.