Think.Python

5星(超过95%的资源)
所需积分/C币:10 2016-01-21 15:10:52 10.85MB PDF
6
收藏 收藏
举报

学习Python的经典书籍。
Think python Allen b. downey ○ REILLY Beijing: Cambridge: Farnham·kdln· Sebastopol· Tokyo Think Python y Allen B. Downey Copyright O 2012 Allen Downey. All rights reserved Printed in the United States of America Published by o reilly media, Inc, 1005 Gravenstein Highway North, Sebastopol, CA 95472 O Reilly books may be purchased for educational, business, or sales promotional use. Online editions are alsoavailableformosttitles(http://my.safaribooksonline.com).Formoreinformationcontactourcorporate institutionalsalesdepartment800-998-9938orcorporate@oreilly.com Editors: Mike Loukides and Meghan Blanchette Proofreader: Stacie arellano Production Editor: Rachel Steely Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: robert romano and rebecca demarest August 2012 First edition Revision history for the First Edition: 2012-08-03 First release Seehttp://oreilly.com/catalog/errata.csp?isbn=9781449330729forreleasedetails Nutshell Handbook, the Nutshell Handbook logo, and the O Reilly logo are registered trademarks ofO Reilly Media, Inc. Think Python, the image of a Carolina Parrot, and related trade dress are trademarks of O Reilly Media Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O Reilly Media, InC, was aware of a trade mark claim, the designations have been printed in caps or initial caps Think Python is available under the Creative Commons Attribution-Non Commercial 3.0 Unported License Theauthormaintainsanonlineversionathttp://thinkpython.com/thinkpython.pdf. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN:978-1-449-33072-9 [LSI Table of contents Preface 1. The Way of the Program. The Python Programming Language What Is a Program? What Is debugging? Syntax error Runtime errors Semantic errors Experimental Debugging Formal and Natural Languages The First Program 113444556789 gging Glossary Exercises 2. Variables, Expressions, and Statements. ,13 Values and Types 13 Variables Variable Names and Keywords 15 Operators and operands 16 Expressions and Statements 16 Interactive Mode and Script mode 17 Order of operations 18 String operations Comments 19 gging 19 Glossary 20 Exercises 21 3. Functions 23 Function calls Type Conversion Functions 23 Math functions 24 Composition 25 Adding New Functions 25 Definitions and Uses 27 Flow of execution 27 Parameters and Arguments 28 Variables and parameters are local 29 Stack Diagrams 30 Fruitful functions and void Functions 31 Why Functions? 32 Importing with from 32 Debugging 33 Glossary 33 Exercises 35 4. Case Study: Interface design 37 Turtle World 37 Simple repetition 38 Exercises 39 Encapsulation Generalization 41 Interface Design 42 Refactoring A Development plan 44 Docstring 44 Debugging Glossa Exercises 5. Conditionals and recursion Modulus operator 49 Boolean expressions Lo ical o peI 50 Conditional execution 50 Alternative execution 51 Chained Conditionals 51 Nested Conditionals 52 iv Table of Contents R excursion 53 Stack Diagrams for Recursive Functions 54 Infinite Recursion K eyboard inpu Debugging 56 Glossary 57 Exercises 58 6. Fruitful functions 61 Return values 61 Incremental Development 62 Composition Boolean functions More recursion Leap of faith 68 One more example 68 Checking Types 69 Debugging 70 Glossary 71 Exercises 7. teration....................9.4...75 Multiple assignment 75 Updating Variabl 76 The while Statement break R algorithms Deb gging 81 Glossary 81 Exercises 82 8. Strings A String Is a Sequence n Traversal with a for Loop 86 String slic 87 Strings Are Immutable 88 Searchin g Looping and Counting String methods 90 The in Operator 91 Table of conten String Comparison 92 Debugging 92 94 Exercises 95 9. Case Study: Word Play. Reading Word lists 97 Exercises 8 Search 9 Looping with indices 100 Deb gging 102 Glossary 102 Exercises 103 10. Lists 105 A List Is a Sequence 105 Lists are mutable 106 Traversing a List List operations 107 List slices 108 List methods 108 Map, Filter, and Reduc 109 Deleting Elements 111 Lists and Strings 112 Objects and values 112 Aliasing 113 List Arguments 114 Debugging 116 Glossar 117 Exercises 118 1. Dictionaries ,,121 Dictionary as a Set of Counters 123 Looping and Dictionaries 124 Reverse lookup 125 Dictionaries and lists 126 Memos 128 Global Variables 129 Long integers 130 Debugging 131 Glossary 132 vi Table of Contents Exercises 133 12. Tuples..... 35 Tuples are Immutable 135 Tuple Assignment 136 Tuples as Return values 137 Variable-Length argument Tuples 137 Lists and Tuples 138 Dictionaries and Tuples 139 Comparing Tuples 141 Sequences of Sequences 142 Debugging 143 Glossary 144 E 144 13.〔 ase Study: Data Structure selection.……147 Word frequency analysis 147 Random numbers 148 Word histogram 149 Most Common words 150 Optional Parameters 151 Dictionary Subtraction 151 Random words 152 Markov analysis 153 Data structures 154 Debugging 156 assar 157 Exercises 158 14. Files 159 Persistence 159 Reading and Writing 159 Format Operator 160 Filenames and paths 161 Catching Exceptions 162 Databases 163 Pickling 164 Pil 165 Writing Modules Debugging 167 Glossary 168 Table of contents|ⅶil Exercises 169 15. Classes and objects. ,171 User-Defined Types 171 Attributes 172 Rectangles 173 stances as return values 174 Objects Are Mutable 175 C opsin g 176 Debugging 177 Glossary 178 Exercises 178 16. Classes and functions 181 Tir me 181 Pure Functions 182 Modifiers 183 Prototyping Versus Planning 184 Debugging 185 Glossary 186 Exercises 187 17. Classes and methods 189 Object-Oriented Features 189 Printing Objects 190 Another Example 191 A More Complicated Example 192 The init Method 192 The str Method 193 Operator Overloading 194 Type-Based Dispatch 194 Polymorphism 196 Debugging 197 Interface and implementation 197 assar 198 Exercises 199 18.InheritanCe.,201 Card Objects 201 Class Attributes 202 Comparing Cards 204 Decks 205 viii Table of Contents

...展开详情
试读 127P Think.Python
立即下载 身份认证后 购VIP低至7折
一个资源只可评论一次,评论内容不能少于5个字
吥_悔 不错不错,值得学习!
2016-07-11
回复
cjycjy09039 nice,英文版的,好好研究
2016-05-25
回复
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 领英

  • GitHub

  • 脉脉勋章

  • 回归勋章

  • 签到新秀

关注 私信
上传资源赚钱or赚积分
最新推荐
Think.Python 10积分/C币 立即下载
1/127
Think.Python第1页
Think.Python第2页
Think.Python第3页
Think.Python第4页
Think.Python第5页
Think.Python第6页
Think.Python第7页
Think.Python第8页
Think.Python第9页
Think.Python第10页
Think.Python第11页
Think.Python第12页
Think.Python第13页
Think.Python第14页
Think.Python第15页
Think.Python第16页
Think.Python第17页
Think.Python第18页
Think.Python第19页
Think.Python第20页

试读结束, 可继续阅读

10积分/C币 立即下载