没有合适的资源?快使用搜索试试~ 我知道了~
首页Python 3编程初学者指南:从基础到高级概念详解
"《002 - 初学者指南:Python 3编程入门》是一本针对Python 3编程的教材,专为初学者设计。它详细地介绍了编程基础概念,例如变量、数据在内存中的存储、for循环以及字符串的使用。作者约翰·亨特以易于理解的方式讲解了函数、模块和包等核心概念,同时涵盖了面向对象编程和函数式编程的重要原理。 书中特别关注了一些容易被误解的主题,如生成器和协程,通过实例深入剖析这些高级特性。另外,诸如引用透明性、多重继承和异常处理等技术,作者也通过具体的例子来阐述其工作原理,确保读者能够掌握它们的实际应用。 这本书的特点在于提供大量的实例和案例研究,包括一些完整的项目示例,旨在帮助读者将理论知识转化为实际操作技能。'大学计算机科学本科课程系列'的编辑们,如伊恩·麦克基、萨姆森·阿布拉姆斯基等人,共同确保了内容的专业性和深度,适合计算机科学各个阶段的学生,无论是基础知识还是高级主题,都能在此找到适用的指导。 总体来说,《002 - 初学者指南:Python 3编程入门》是一本全面且实用的教程,无论你是初次接触编程,还是希望提升Python 3技能的开发者,都能从中获益匪浅。通过本书,读者不仅能建立起坚实的编程基础,还能学习如何高效地运用Python进行问题解决和软件开发。"
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/12387665/bg10.jpg)
5.7.3 Floating Point Number Operators............... 60
5.7.4 Integers and Floating Point Operations
........... 60
5.7.5 Complex Number Operators
.................. 61
5.8 Assignment Operators
.............................. 61
5.9 None Value
..................................... 62
5.10 Online Resources ................................. 63
5.11 Exercises
....................................... 63
5.11.1 General Exercise
........................... 64
5.11.2 Convert Kilometres to Miles
.................. 64
6 Flow of Control Using If Statements
........................ 65
6.1 Introduction
..................................... 65
6.2 Comparison Operators
.............................. 65
6.3 Logical Operators
................................. 66
6.4 The If Statement .................................. 66
6.4.1 Working with an If Statement
................. 67
6.4.2 Else in an If Statement
...................... 68
6.4.3 The Use of elif
............................ 68
6.5 Nesting If Statements
.............................. 69
6.6 If Expressions
.................................... 70
6.7 A Note on True a nd False
........................... 71
6.8 Hints
.......................................... 72
6.9 Online Resources ................................. 72
6.10 Exercises
....................................... 72
6.10.1 Check Input Is Positive or Negative
............. 72
6.10.2 Test if a Number Is Odd or Even
.............. 73
6.10.3 Kilometres to Miles Converter
................. 73
7 Iteration/Looping
...................................... 75
7.1 Introduction
..................................... 75
7.2 While Loop
..................................... 75
7.3 For Loop ....................................... 77
7.4 Break Loop Statement
.............................. 79
7.5 Continue Loop Statement
........................... 81
7.6 For Loop with Else
................................ 82
7.7 A Note on Loop Variable Naming
..................... 83
7.8 Dice Roll Game
.................................. 83
7.9 Online Resources
................................. 84
7.10 Exercises
....................................... 84
7.10.1 Calculate the Factorial of a Number ............. 84
7.10.2 Print All the Prime Numbers in a Range
......... 85
Contents xvii
![](https://csdnimg.cn/release/download_crawler_static/12387665/bg11.jpg)
8 Number Guessing Game ................................. 87
8.1 Introduction
..................................... 87
8.2 Setting Up the Program
............................. 87
8.2.1 Add a Welcome Message
.................... 87
8.2.2 Running the Program
....................... 88
8.3 What Will the Program Do? ......................... 89
8.4 Creating the Game
................................ 90
8.4.1 Generate the Random Number
................. 90
8.4.2 Obtain an Input from the User
................. 91
8.4.3 Check to See If the Player Has Guessed the
Number
................................. 91
8.4.4 Check They Haven’ t Exceeded Their Maximum
Number of Guess
.......................... 92
8.4.5 Notify the Player Whether Higher or Lower ....... 93
8.4.6 End of Game Status
........................ 94
8.5 The Complete Listing
.............................. 94
8.6 Hints
.......................................... 96
8.6.1 Initialising Variables
........................ 96
8.6.2 Blank Lines Within a Block of Code
............ 96
8.7 Exercises
....................................... 97
9 Recursion
............................................ 99
9.1 Introduction ..................................... 99
9.2 Recursive Behaviour
............................... 99
9.3 Benefits of Recursion
.............................. 100
9.4 Recursively Searching a Tree
......................... 100
9.5 Recursion in Python
............................... 102
9.6 Calculating Factorial Recursi vely
...................... 102
9.7 Disadvantages of Recursion
.......................... 104
9.8 Online Resources
................................. 105
9.9 Exercises ....................................... 105
10 Introduction to Structured Analysis
........................ 107
10.1 Introduction
..................................... 107
10.2 Structured Analysis and Function Identification
............ 107
10.3 Functional Decomposition
........................... 108
10.3.1 Functional Decomposition Terminology
.......... 109
10.3.2 Functional Decomposition Process
.............. 110
10.3.3 Calculator Functional Decomposition Example
..... 110
10.4 Functional Flow .................................. 112
10.5 Data Flow Diagrams
............................... 112
10.6 Flowcharts
...................................... 113
10.7 Data Dictionary
................................... 115
10.8 Online Resources
................................. 116
xviii Contents
![](https://csdnimg.cn/release/download_crawler_static/12387665/bg12.jpg)
11 Functions in Python .................................... 117
11.1 Introduction
..................................... 117
11.2 What Are Functions?
............................... 117
11.3 How Functions Work
.............................. 118
11.4 Types of Functions
................................ 118
11.5 Defining Functions ................................ 119
11.5.1 An Example Function
....................... 120
11.6 Returning Values from Functions
...................... 121
11.7 Docstring
....................................... 123
11.8 Function Parameters
............................... 124
11.8.1 Multiple Parameter Functions
................. 124
11.8.2 Default Parameter Values
.................... 125
11.8.3 Named Arguments
......................... 126
11.8.4 Arbitrary Arguments ........................ 127
11.8.5 Positional and Keyword Arguments
............. 128
11.9 Anonymous Functions
.............................. 129
11.10 Online Resources
................................. 131
11.11 Exercises
....................................... 131
12 Scope and Lifetime of Variables
........................... 133
12.1 Introduction
..................................... 133
12.2 Local Variables
................................... 133
12.3 The Global Keyword ............................... 135
12.4 Nonlocal Variables
................................ 136
12.5 Hints
.......................................... 137
12.6 Online Resources
................................. 138
12.7 Exercise
........................................ 138
13 Implementing a Calculator Using Functions
.................. 139
13.1 Introduction
..................................... 139
13.2 What the Calculator Will Do
......................... 139
13.3 Getting Started ................................... 140
13.4 The Calculator Operations
........................... 140
13.5 Behaviour of the Calculator
.......................... 141
13.6 Identifying Whether the User Has Finished
............... 142
13.7 Selecting the Operation
............................. 144
13.8 Obtaining the Input Numbers
......................... 146
13.9 Determining the Operation to Execute
.................. 147
13.10 Running the Calculator
............................. 147
13.11 Exercises ....................................... 148
14 Introduction to Functional Programming
.................... 149
14.1 Introduction
..................................... 149
14.2 What Is Functional Programming?
..................... 149
Contents xix
![](https://csdnimg.cn/release/download_crawler_static/12387665/bg13.jpg)
14.3 Advantages to Functional Programming ................. 151
14.4 Disadvantages of Functional Programming
............... 153
14.5 Referential Transparency
............................ 153
14.6 Further Reading
.................................. 155
15 Higher Order Functions
................................. 157
15.1 Introduction ..................................... 157
15.2 Recap on Functions in Python
........................ 157
15.3 Functions as Objects
............................... 158
15.4 Higher Order Function Concepts
...................... 160
15.4.1 Higher Order Function Example
............... 161
15.5 Python Higher Order Functions
....................... 162
15.5.1 Using Higher Order Functions
................. 163
15.5.2 Functions Returning Functions
................ 164
15.6 Online Resources ................................. 165
15.7 Exercises
....................................... 165
16 Curried Functions
...................................... 167
16.1 Introduction
..................................... 167
16.2 Currying Concepts
................................ 167
16.3 Python and Curried Functions
........................ 168
16.4 Closures
........................................ 170
16.5 Online Resources
................................. 172
16.6 Exercises ....................................... 173
17 Introduction to Object Orientation
......................... 175
17.1 Introduction
..................................... 175
17.2 Classes
......................................... 175
17.3 What Are Classes for?
.............................. 176
17.3.1 What Should a Class Do?
.................... 177
17.3.2 Class Terminology
......................... 177
17.4 How Is an OO Sy stem Constructed?
................... 178
17.4.1 Where Do We Start? ........................ 179
17.4.2 Identifying the Objects
...................... 180
17.4.3 Identifying the Services or Methods
............. 181
17.4.4 Refining the Objects
........................ 182
17.4.5 Bringing It All Together
..................... 183
17.5 Where Is the Structure in an OO Program?
............... 186
17.6 Further Reading
.................................. 188
18 Python Classes
........................................ 189
18.1 Introduction ..................................... 189
18.2 Class Definitions
.................................. 190
18.3 Creating Examples of the Class Person
.................. 191
18.4 Be Careful with Assignment
......................... 192
xx Contents
![](https://csdnimg.cn/release/download_crawler_static/12387665/bg14.jpg)
18.5 Printing Out Objects ............................... 194
18.5.1 Accessing Object Attributes
................... 194
18.5.2 Defining a Default String Representation
......... 195
18.6 Providing a Class Comment
.......................... 196
18.7 Adding a Birthday Method
.......................... 197
18.8 Defining Instance Methods .......................... 198
18.9 Person Class Recap
................................ 199
18.10 The del Keyword
................................. 200
18.11 Automatic Memory Management
...................... 201
18.12 Intrinsic Attributes
................................ 202
18.13 Online Resources
................................. 203
18.14 Exercises
....................................... 203
19 Class Side and Static Behaviour
........................... 205
19.1 Introduction ..................................... 205
19.2 Class Side Data
................................... 205
19.3 Class Side Methods
................................ 206
19.3.1 Why Class-Side Methods?
.................... 207
19.4 Static Methods
................................... 207
19.5 Hints
.......................................... 208
19.6 Online Resources
................................. 208
19.7 Exercises
....................................... 209
20 Class Inheritance
...................................... 211
20.1 Introduction
..................................... 211
20.2 What Is Inheritance?
............................... 211
20.3 Terminology Around Inheritance
...................... 215
20.4 The Class Object and Inheritance
...................... 217
20.5 The Built-in Object Class
........................... 218
20.6 Purpose of Subclasses
.............................. 218
20.7 Overriding Methods
............................... 219
20.8 Extending Superclass Methods ........................ 221
20.9 Inheritance Oriented Naming Conventions
............... 222
20.10 Python and Multiple Inheritance
...................... 223
20.11 Multiple Inheritance Considered Harmful
................ 225
20.12 Summary
....................................... 230
20.13 Online Resources
................................. 230
20.14 Exercises
....................................... 231
21 Why Bother with Object Orientation?
...................... 233
21.1 Introduction ..................................... 233
21.2 The Procedural Approach
........................... 233
21.2.1 Procedures for the Data Structure
.............. 234
21.2.2 Packages
................................ 235
Contents xxi
剩余440页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/default.jpg!1)
Michel2020
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 中国微型数字传声器:技术革新与市场前景
- 智能安防:基于Hi3515的嵌入式云台控制系统设计
- 手机电量低时辐射真增千倍?解析手机使用谣言
- 56F803型DSP驱动的高精度大功率超声波电源控制策略研究
- ARM与GPRS结合的远程监测系统设计
- GPS与RFID技术结合的智能巡检系统设计
- CPLD驱动的低功耗爆炸场温度测试系统设计
- 基于FPGA的智能驱动控制系统:可扩展设计与工业网络协议
- 基于ATmega128和CH374的嵌入式USB接口设计
- 基于AT89C52的温度补偿超声波测距仪:高精度设计与应用
- MSP430F448单片机在交流数字电压表中的应用
- 提升变频器应用效率的12项实用技巧
- STM32F103在数字电镀电源并联均流系统中的应用
- PSpice仿真下的升压开关电源设计:拓扑分析与CCM稳定性提升
- 轻巧高效:MSP430主导的低成本无线传感器网络节点设计
- FPGA在EDA/PLD中实现LVDS接口的应用解析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)