Chapter 2. Simple Data Types
Now we'll look at a number of data types that are built-in as well as some that are part of Python's standard library. We'll start with Python's numeric types. These include three built-in types: int
, float
, and complex
, plus the standard library types Fraction
and Decimal
.
We'll also look at strings, str
, and simple collections, tuple
. These are more complex than numbers because they contain multiple items. Since their behavior is less complex than the kinds of objects we'll see in later chapters, they serve as a good introduction to the general concept of sequences in Python.
Note the capitalization of the names of Fraction
and Decimal
. The built-in type names start with a lowercase letter. Types that we must import ...
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.