Chapter 3. Data Types and Structures
Bad programmers worry about the code. Good programmers worry about data structures and their relationships.
Linus Torvalds
This chapter introduces the basic data types and data structures of Python, and is organized as follows:
- “Basic Data Types”
-
The first section introduces basic data types such as
int
,float
,bool
, andstr
. - “Basic Data Structures”
-
The second section introduces the fundamental data structures of Python (e.g.,
list
objects) and illustrates, among other things, control structures, functional programming approaches, and anonymous functions.
The aim of this chapter is to provide a general introduction to Python specifics when it comes to data types and structures. The reader equipped with a background from another programing language, say C or Matlab, should be able to easily grasp the differences that Python usage might bring along. The topics and idioms introduced here are important and fundamental for the chapters to come.
The chapter covers the following data types and structures:
Object type | Meaning | Used for |
---|---|---|
|
Integer value |
Natural numbers |
|
Floating-point number |
Real numbers |
|
Boolean value |
Something true or false |
|
String object |
Character, word, text |
|
Immutable container |
Fixed set of objects, record |
|
Mutable container |
Changing set of objects |
|
Mutable container |
Key-value store |
|
Mutable container |
Collection of unique objects |
Basic Data Types
Python is a dynamically ...
Get Python for Finance, 2nd Edition 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.