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.,
listobjects) 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access