Catalogs
Foreword
Chapter 1 Overview of Python 1
1.1 Python overview 1
1.2 Development environment3
1.3 Summary of this chapter 5
Chapter 2 Python language basics7
2.1 Python program composition7
2.2 Packages, modules, and functions8
2.3 Identifier and its naming rules 11
2.4 Common data types13
2.5 Operators and expressions 18
2.6 Objects and references 23
2.7 Inputs and outputs27
2.8 Summary of this chapter 31
Chapter 3 Branch structure 33
3.1 Flow charts and three structures33
3.2 Operators and precedence 37
3.3 Branch structure (single, double, multi-branch and nested)41
3.4 Summary of this chapter 47
Chapter 4 Loop structure49
4.1 The while loop and the sentinel loop 49
4.2 For statements and nested loops52
4.3 Iterable objects 56
4.4 Built-in function range56
4.5 The break statement, continue statement and else clause 58
4.6 Getting started with data science 63
4.7 Summary of this chapter 64
Chapter 5 Lists and Tuples66
5.1 Sequences66
5.2 Lists67
5.3 Tuples86
5.4 Unpacking and packing89
5.5 Summary of this chapter 91
Chapter 6 Dictionaries and Collections92
6.1 Dictionaries 926.2 Assemblies 99
6.3 Summary of this chapter 103
Chapter 7 String 104
7.1 Definition of the string 104
7.2 Escape characters and original strings 104
7.3 String formatting 105
7.4 Common operations on strings 108
7.5 Regular expressions112
7.6 Summary of this chapter116
Chapter 8 Functions 117
8.1 Define and call the function117
8.2 Passing arguments 119
8.3 Variable scopes 122
8.4 Recursive functions 124
8.5 Built-in functions and the Python standard library 126
8.6 Summary of this chapter 129
Chapter 9 Modules 131
9.1 Module Overview 131
9.2 Importing modules 132
9.3 Packages in Python 134
9.4 Referencing other modules 135
9.5 Summary of this chapter 138
Chapter 10 Object-Oriented Programming 139
10.1 Overview of object-oriented programming 139
10.2 Class definition and instantiation 141
10.3 Attributes and methods 143
10.4 Inheritance 150
10.5 Summary of this chapter 154
Chapter 11 Exception Handling and Program Debugging 155
11.1 Overview of Exceptions 155
11.2 Exception handling statements 156
11.3 Program debugging 159
11.4 Summary of this chapter 162
Chapter 12 File and Directory Operations 163
12.1 Definition of file 163
12.2 Directory Operations 164
12.3 File Op