文件名称:
Fundamentals_of_Python_From_First_Programs_through_Data_Structures_2009.pdf.pdf
开发工具:
文件大小: 11mb
下载次数: 0
上传时间: 2019-09-13
详细说明:Fundamentals_of_Python_From_First_Programs_through_Data_Structures_2009.pdfFundamentals of
Python
From First Programs
Through Data Structures
Kenneth A. Lambert
Martin Osborne, Contributing Author
COURSE TECHNOLOGY
CENGAGE Learning
Australia. Brazil Japan Korea. Mexico Singapore Spain- United Kingdom. United States
COURSE TECHNOLOGY
P CENGAGE Learning"
Fundamentals of Python: From First
O)2010 Course Technology, Cengage Learning
Programs Through Data Structures
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Kenneth A. Lambert
herein may be reproduced, transmitted, stored or used in any form or by
Executive EdiTor: Marie Lee
any means graphiC, electronic, or mechanical, including but not limited Lo
photocopying, recording, scanning, digitizing, taping, Web distribution,
Acquisitions Editor: Amy Jollymore
information networks, or information storage and retrieval systems, except
Senior Product Manager Alyssa pratt
as permitted under Section 107 or 108 of the 1976 United States Copyright
Development Editor: Ann Shaffer
Act, without the prior written permission of the publisher.
Editorial Assistant: Julia Leroux-Lindsey
Marketing Manager: Bryant Chrzan
For product information and technology assistance, contact us at
Cengage Learning Customer Sales Support, 1-800-354-9706
Content Project Manager: Matt Hutchinson
For permission to use material from this text or praduct, submit al
Art director: marissa falco
requestsonlineatwww.cengage.com/permissions
Compositor: Gex Publishing Services
Further permissions questions can be emailed to
permissionrequestcengage.com
SBN-13:978-1-4239-0218-8
SBN-10:1-4239-0218-1
Course Technol
Boston Massachusetts 02210
USA
Cengage Learning is a leading provider of customized learning solutions
ith office locations around the globe, including Singapore, the United
Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at
international cengage. com/region
Cengage Learning products are represented in Canada by Nelson
Education ltd
Foryourlifelonglearningsolutionsvisitcoursecengage.com
Purchase any of our products at your local college store or at our preferred
onlinestorewww.ichapters.com
Some of the product names and company names used in this book have
ly and may
tered trademarks of their respective manufacturers and sellers.
Any fictional data related to persons or companies or URLs used through
ut this book is intended for instructional
ly. At the time this
book
d, any such data was fictional and not belonging to any real
persons or companles
engage Learning, reserve
and make changes from time to time in its
The programs in this book are for instructional purposes only
They have been tested with care, but are not guarante
any parti
intent beyond educational purposes. The author and the publisher do not
nties or representations, nor do they accept any liabilities
ith
to the
Printed in canad
12345671211100908
欢迎加入非盈利 Python蝙程学习交流Q群/83452347,群里免表提供5004本 Pyt hon籍
Table of contents
[CHAPTER]1INTRODUCTION
Two Fundamcntal Idcas of Computcr Scicncc: Algorithms and Information
P
g
1.1.1 Algorithms
1.1.2
Exercises
12
Thc Structurc of a mode
1.2. 1 CoInputer Hardw
1.2.2 Computer Software
1.2
Exercises
1.3
A Not-So-Brief History of Computing Systems
10
1.3.1 Before Electronic Digital Computers
1.3.2 The First Electronic Digital Computers(1940-1950
1.3.3 The First Programming Languages(1950-1965)
1.3.4 Integrated Circuits, Interaction, and Timesharing (1965-1975).18
1.3.5 Personal Computing and Networks(1975-1990
1.3. 6 Consultation, Communication, and Ubiquitous Computing
(1990-Present)....
1.4
Getting Started with Python programming
1.4.1 Running Code in the Interactive Shell
1.4.2
ng
1.4.3 Editing, Saving, and Running a Script.
27
1.4.4 Behind the Scenes: Hlow Python Works.....
29
1.4
E
1.5
Detecting and Correcting Syntax errors
1.5
Exercises
Suggestions for Further Reading
ummary
Review Questions
Projec
[CHAPTER] 2 SOFTWARE DEVELOPMENT, DATA TYPES, AND EXPRESSIONS 39
2.1 Thc Softwarc Dcvclopmcnt Proccss
10
2.1
2.2
2.2.1 Request
2.2.2 Anal
2.2.4 Implernentation(Coding)
2.2.5 Testing
欢迎加入非盈利 Python编程学习交流Q群783462347,群里免费提供500+本 Pyt hon籍
2.3 Strings, Assignment, and Comments
23.1D
g
2.3.3
scape Sequences
2.3.4 String Concatenation
2.3.6 PrograIn Cotlmlents and Docstring t
2.3.5 variabl
2.3
2.4
Numeric Data Types and Character Sets
241 Integers and Long Integers………
2.4.2 Floating-Point Numbers
2. 4.3 Character Sets
2.4
Exercise:
2.5 Expressions
2.5.1 Arithmetic Expressions
2.5.2 Mixcd-Modc Arithmetic and Typc Conversions
2.5
2.6
Using Functions and module
2.6.1 Calling Functions: Arguments and Return values
2.6.2The math Module
2.6.3 Thc Main Module.
2.6.4 Program Format and Structure
2.6.5 Running a Script from a Terminal Command Prompt
2.6
Summary
Review Questions
Projects
[CHAPTER]3 CONTROL STATEMENTS
3.
Definite iteration: The for loop……
76
3.1.1 Executing a Statement a Given Number of Times...76
3.1.2 Count-Controlled Loops
3.1.3 Augmented Assignment
3.1.4 Loop Errors: Off-by-One Frror
3.1.5'lraversing the Contents of a Data Sequence
3.1.6
Specifying the Steps in the range
3. 1.7 Loops That Count Down
82
3.1
Exerci
3.2
F
3.2
3.3
Case Study: An Investment Report..
…87
3.3.2 Analy
333D
3.3.4 Imple
3.3.5 Testing
3,4
Sclcction: if and if-else statcmcnts
91
3.4.1 The Boolean Type, Comparisons, and Boolean Expressions..91
3. 4.2 if-else Statements
欢迎加入非盈利 Python蝙程学习交流Q群/83452347,群里免表提供5004本 Pyt hon籍
3.4.3 One-Way Selection Statements
3.4.4 Multi-way if Statements.........
95
3.4.5 Logical Operators and Compound Boolean Expressions
3.4.6 Short-Circuit Evaluation
3.4.7 Testing Selection Statements.........
3.4
101
3.5
Conditional Iteration: The while loop
3.5.1 The Structure and Behavior of a while Loop
3.5.2 Count Control with a while Loop
3.5.3 The while True L
nd the break statement
∴105
3.5.4 Random Numbers
107
3.5.5 Loop Logic, Errors, and Testing
109
3.5
109
3.6
Case study: Approximating square roots
110
3.6.1
110
362 analysis.…
110
363D
110
3.6.4 Implementation( Coding)
112
36.5
Testing
l13
Summary…
113
Rcvicw Qucstions
116
118
[CHAPTER] 4 STRINGS AND TEXT FILES
121
4.1 Accessing Characters and Substrings in Strings
122
4.1.1 Thc Str
4.1.2 The Subscript Ope
4.1.3 Slicing for Substrings
ng for a Substring with the in Ope
41
Exerci
126
42
D
126
42
Exercises
4.3
and Nuinber s
129
4.3.1 The Positional System for r
130
4. 3.2 Converting Binary to Decimal
131
4.3.3
onverting decimal to Bi
132
4.3.4 Conversion Shortcut
133
4.3.5 Octal and Hexadecimal Numbers
4.3
F
4.4
String methods
4,4
Exercises
140
4
Text files
4.5.1 Text Files and Their Furr
4.5.2 Writing Text to a file
.142
4.5.3 Writing Numbers to a File
4.5.4 Reading ' lext from a File...........143
4.5.5 Rcading Numbcrs from a Filc
145
4.5.6 Accessing and Manipulating Files and Directories on Disk
146
欢迎加入非盈利 Python编程学习交流Q群783462347,群里免费提供500+本 Pyt hon籍
45
148
4.6 Case Study: Text Analysis
148
46.1R
4.6.2 Analysis....
149
463D
150
4.6.4 Implementation( Coding)
151
4.6.5 Testing
Summa
Review Questions…
[CHAPTER] 5 LISTS AND DICTIONARIES
159
5.1
160
5.1.1 List Literals and Basic Operators
5.1.2 Replacing an Element in a
163
5.1.3 List Methods for Inserting and Removing Elements
514S: arching a list………
167
515S
168
5.1.6 Mutator Methods and the Value None
l68
5.1.7 Aliasing and Side Effects
169
5.1.8 Equality: Objcct Identity and Structural Equivalence
171
5.1.9 ExaImple: Using a List to Find the Median of a Set of Nunbers.172
5.1.10 Tuples
5.1
.174
5.2
Defining Simple Functions......
175
5.2.1 Thc Syntax of Simplc Function Dcfinitions
175
5.2.2 Parameters and Arguments
176
5.2.3 The return Statement
5.2.4 Boolean Functions
5.2.5 Defining a main Function
178
5.2
179
53
Case study Generating Sentences
.179
531R
179
5.3.2 Analysis
5.3.3
Design
5.3.4 Implementation( Coding)
5.3.5 Testing
183
5.4
Dictionaries
183
5.4.1 Dictionary Literals.
.183
5.4.2 Adding Keys and Replacing Values
184
5.4.3
value
5.4
K
5.4.5 Traversing a Dictionary
186
5.4.6 Example: The Hexadecimal System Revisited.....188
5.4.7 Example: Finding the Mode of a List of Values
189
Xercises
欢迎加入非盈利 Python蝙程学习交流Q群/83452347,群里免表提供5004本 Pyt hon籍
5.5 Case Study: Nondirective Psychotherapy
191
5.51R
5.5.2
5.5.3
Design……
192
554 Implementation( Coding)……
193
5.5.5 Testins
195
Summary
195
R
stion
P
l98
[CHAPTER]6DESIGN WITH FUNCTIONS
201
61
unctions as abstraction mechanisms
202
6.1.1 Functions Eliminate Redundancy
6.1.2 Functions Hide Complexity
203
6.1.3 Functions Support General Methods with Systematic Variations. 204
6. 1.4 Functions Support the Division of Labor
205
61
Exercises
05
6.2
Problem Salving with Top-Down Design
206
6.2.1 The Design of the Text-Analysis Program
206
6.2.2 The Design of the Sentence-Generator Program
207
6.2.3 Thc Dcsign of the Doctor Program
209
62
Exercises
.210
63
Design with Recursive Functions
“--+“-++=-+
211
6.3.1 Defining a Recursive Function
2l1
6.3.2 Iracing a Recursive Function
213
6.3.3 Using Rccursive Dcfinitions to Co
6.3.4 Recursion in Sentence Structure
6.3.5 Infinite Recursion
215
6.3.6 The Costs and Benefits of Recursion
216
6,3
6,4
Case Study: Gathering Information from a File System………
219
6. 4.1 Request
219
6.4.2 Analvsis
220
64.3T
22
6.4.4 Implementation( Coding)......
65
Managing a Programs Namespace……
6.5.1 Module Variables, Parameters, and Temporary Variables
227
652S
28
6.5.3T.ifetime
229
6.5.4Default
230
6.5
Exert
66
Higher-Order Functions(Advanced Topic
6.6.1 Functions as First-Class Data Objects
66.2 Mapping……
66.3
Filtering……
66.4
6.6.5 Using lambda to Crcatc Anonymous Functions
237
6.6.6 Creating Jump Tables
238
欢迎加入非盈利 Python编程学习交流Q群783462347,群里免费提供500+本 Pyt hon籍
66
SuIIlImarv
240
Review Ouestions
Project
244
[] 7 SIMPLE GRAPHICS AND IMAGE PROCESSING
247
7.1 Simple Graphics
248
7.1.1 Overview of Turtle Graphics
248
71.2
turtle Operations
249
71.3 Object Instantiation and the turtlegraphics Module
7.1.4 Drawing Two-Dimensional Shapes
.254
7.1.5 Taking a Random Walk.
7.1.6 Colors and the RGB System
71.7
ple: Drawing with Random color
7.1.8 Using the str Function with Objects
Exercises……
260
72
Case study: Recursive Patterns in Fractals
72.1
262
7.2.2 Analysis
262
723
263
7.2.4 Implementation(Coding)
73
IImage processing
266
7.3.1 Analog and Digital Information
266
7.3.2 Sampling and Digitizing Images
267
73.3 Image File Format
7.3.4 Imagc-Manipulation Opcrations
268
73.5
mages∴
73.6
e mades
ovule
269
7.3.7 A Loop Pattern for Traversing a Grid
73.8
A Word on tuples
73.9 Converting an Image to Black and White.
73. 10 Converting an Image to Grayscale
277
7.3.11 Copy
7.3.12 Blurring an Image
279
73.13 Edge Detection…
280
73.14 Red
73
Exercises
Review or
[CHAPTER]8DESIGN WITH CLASSES
291
8.1
Getting Inside Objects and classes
8.1.1 A First Example: The Student Class
293
8.1.2 Docs
296
8.1.3 Method Definitions
296
8.1.4 The init Method and Instance Var
8.1.5 The s
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.