In this chapter we’ll begin by looking at Python’s simplest built-in data types:
3.14159, or sometimes exponents like
1.0e8, which means one times ten to the eighth power, or
In a way, they’re like atoms. We’ll use them individually in this chapter. Chapter 3 shows how to combine them into larger “molecules.”
Each type has specific rules for its usage and is handled differently by the computer. We’ll also introduce variables (names that refer to actual data; more on these in a moment).
The code examples in this chapter are all valid Python, but they’re snippets.
We’ll be using the Python interactive interpreter,
typing these snippets and seeing the results immediately.
Try running them yourself with the version of Python on your computer.
You’ll recognize these examples by the
In Chapter 4, we start writing Python programs that can run on their own.
In Python, everything—booleans, integers, floats, strings, even large data structures, functions, and programs—is implemented as an object. This gives the language a consistency (and useful features) that some other languages lack.
An object is like a clear plastic box that contains a piece of data (Figure 2-1). The object has a type, such as boolean ...