您好,欢迎光临本网站![请登录][注册会员]  
文件名称: thinkCSpy.pdf
  所属分类: Python
  开发工具:
  文件大小: 856kb
  下载次数: 0
  上传时间: 2019-08-19
  提 供 者: drji*****
 详细说明: xviii Contents 2.7 Orderofoperations......................... 16 2.8 Operationsonstrings........................ 17 2.9 Composition............................. 18 2.10 Comments.............................. 18 2.11 Glossary............................... 19 3 Functions 21 3.1 Functioncalls............................ 21 3.2 Typecon version........................... 22 3.3 Typecoercion............................ 22 3.4 Mathfunctions........................... 23 3.5 Composition............................. 24 3.6 Addingnewfunctions ....................... 25 3.7 Definitionsanduse......................... 27 3.8 Flowofexecution.......................... 28 3.9 Parametersandarguments..................... 28 3.10 Variablesandparametersarelocal................ 30 3.11 Stackdiagrams........................... 30 3.12 Functionswithresults....................... 32 3.13 Glossary............................... 32 4 Conditionalsandrecursion 35 4.1 Themodulusoperator....................... 35 4.2 Booleanexpressions ........................ 35 4.3 Logicaloperators.......................... 36 4.4 Conditionalexecution ....................... 37 4.5 Alternativeexecution........................ 37 4.6 Chainedconditionals........................ 38 Contents xix 4.7 Nestedconditionals......................... 39 4.8 Thereturnstatement....................... 40 4.9 Recursion.............................. 40 4.10 Stackdiagramsforrecursivefunctions.............. 42 4.11 Infiniterecursion.......................... 43 4.12 Keyboardinput........................... 43 4.13 Glossary............................... 44 5 Fruitfulfunctions 47 5.1 Returnvalues............................ 47 5.2 Programdevelopment ....................... 48 5.3 Composition............................. 51 5.4 Booleanfunctions.......................... 52 5.5 Morerecursion........................... 53 5.6 Leapoffaith ............................ 55 5.7 Onemoreexample......................... 56 5.8 Checkingtypes........................... 57 5.9 Glossary............................... 58 6 Iteration 59 6.1 Multipleassignment ........................ 59 6.2 Thewhilestatement........................ 60 6.3 Tables................................ 62 6.4 Two-dimensionaltables ...................... 64 6.5 Encapsulationandgeneralization................. 65 6.6 Moreencapsulation......................... 66 6.7 Localvariables........................... 67 6.8 Moregeneralization......................... 68 6.9 Functions.............................. 69 6.10 Glossary............................... 70 xx Contents 7 Strings 71 7.1 Acompounddatatype....................... 71 7.2 Length................................ 72 7.3 Traversalandtheforloop..................... 72 7.4 Stringslices............................. 74 7.5 Stringcomparison ......................... 74 7.6 Stringsareimmutable....................... 75 7.7 Afindfunction........................... 76 7.8 Loopingandcounting ....................... 76 7.9 Thestringmodule ........................ 77 7.10 Characterclassification....................... 78 7.11 Glossary............................... 79 8 Lists 81 8.1 Listvalues.............................. 81 8.2 Accessingelements......................... 82 8.3 Listlength.............................. 83 8.4 Listmembership.......................... 84 8.5 Listsandforloops......................... 84 8.6 Listoperations........................... 85 8.7 Listslices.............................. 86 8.8 Listsaremutable.......................... 86 8.9 Listdeletion............................. 87 8.10 Objectsandvalues......................... 89 8.11 Aliasing............................... 90 8.12 Cloninglists............................. 90 8.13 Listparameters........................... 91 8.14 Nestedlists............................. 92 Contents xxi 8.15 Matrices............................... 92 8.16 Stringsandlists........................... 93 8.17 Glossary............................... 94 9 Tuples 95 9.1 Mutabilityandtuples ....................... 95 9.2 Tupleassignment.......................... 96 9.3 Tuplesasreturnvalues....................... 97 9.4 Randomnumbers.......................... 97 9.5 Listofrandomnumbers...................... 98 9.6 Counting............................... 99 9.7 Manybuckets............................100 9.8 Asingle-passsolution........................102 9.9 Glossary...............................103 10Dictionaries 105 10.1 Dictionaryoperations........................106 10.2 Dictionarymethods.........................107 10.3 Aliasingandcopying........................108 10.4 Sparsematrices ..........................108 10.5 Hints.................................109 10.6 Longintegers............................111 10.7 Countingletters...........................111 10.8 Glossary...............................112 11Filesandexceptions 115 11.1 Textfiles...............................117 11.2 Writingvariables..........................118 11.3 Directories..............................121 xxii Contents 11.4 Pickling...............................121 11.5 Exceptions..............................122 11.6 Glossary...............................124 12Classesandobjects 127 12.1 User-definedcompoundtypes...................127 12.2 Attributes..............................128 12.3 Instancesasarguments.......................129 12.4 Sameness ..............................129 12.5 Rectangles..............................131 12.6 Instancesasreturnvalues.....................132 12.7 Objectsaremutable........................132 12.8 Copying...............................133 12.9 Glossary...............................135 13Classesandfunctions 137 13.1 Time.................................137 13.2 Purefunctions............................138 13.3 Modifiers ..............................139 13.4 Whichisbetter? ..........................140 13.5 Prototypedevelopmentversusplanning .............141 13.6 Generalization............................142 13.7 Algorithms .............................142 13.8 Glossary...............................143 14Classesandmethods 145 14.1 Object-orientedfeatures......................145 14.2 printTime..............................146 14.3 Anotherexample..........................147 Contents xxiii 14.4 Amorecomplicatedexample ...................148 14.5 Optionalarguments.........................149 14.6 Theinitializationmethod.....................150 14.7 Pointsrevisited...........................151 14.8 Operatoroverloading........................152 14.9 Polymorphism............................153 14.10Glossary...............................155 15Setsofobjects 157 15.1 Composition.............................157 15.2 Cardobjects.............................157 15.3 Classattributesandthe str method.............159 15.4 Comparingcards..........................160 15.5 Decks ................................161 15.6 Printingthedeck..........................161 15.7 Shufflingthedeck..........................163 15.8 Removinganddealingcards....................164 15.9 Glossary...............................165 16Inheritance 167 16.1 Inheritance .............................167 16.2 Ahandofcards...........................168 16.3 Dealingcards............................169 16.4 PrintingaHand...........................169 16.5 TheCardGameclass.........................171 16.6 OldMaidHandclass.........................171 16.7 OldMaidGameclass.........................173 16.8 Glossary...............................177 xxiv Contents 17Linkedlists 179 17.1 Embeddedreferences........................179 17.2 TheNodeclass ...........................179 17.3 Listsascollections.........................181 17.4 Listsandrecursion.........................182 17.5 Infinitelists.............................183 17.6 Thefundamentalambiguitytheorem...............184 17.7 Modifyinglists ...........................184 17.8 Wrappersandhelpers .......................185 17.9 TheLinkedListclass.......................186 17.10Invariants..............................187 17.11Glossary...............................188 18Stacks 189 18.1 Abstractdatatypes ........................189 18.2 TheStackADT...........................190 18.3 ImplementingstackswithPythonlists..............190 18.4 Pushingandpopping........................191 18.5 Usingastacktoevaluatepostfix .................192 18.6 Parsing................................192 18.7 Evaluatingpostfix .........................193 18.8 Clientsandproviders........................194 18.9 Glossary...............................195 19Queues 197 19.1 TheQueueADT..........................197 19.2 LinkedQueue............................198 19.3 Performancecharacteristics....................199 Contents xxv 19.4 ImprovedLinkedQueue......................199 19.5 Priorityqueue............................201 19.6 TheGolferclass..........................203 19.7 Glossary...............................204 20Trees 205 20.1 Buildingtrees............................206 20.2 Traversingtrees...........................207 20.3 Expressiontrees...........................207 20.4 Treetraversal............................208 20.5 Buildinganexpressiontree ....................210 20.6 Handlingerrors...........................214 20.7 Theanimaltree...........................214 20.8 Glossary...............................217 ADebugging 219 A.1 Syntaxerrors............................219 A.2 Runtimeerrors...........................221 A.3 Semanticerrors...........................225 BCreatinganewdatatype 229 B.1 Fractionmultiplication.......................230 B.2 Fractionaddition..........................232 B.3 Euclid’salgorithm .........................232 B.4 Comparingfractions........................233 B.5 Takingitfurther..........................234 B.6 Glossary...............................235 xxvi Contents CRecommendationsforfurtherreading 237 C.1 Python-relatedwebsitesandbooks................238 C.2 Recommendedgeneralcomputersciencebooks .........239 DGNUFreeDocumentationLicense 241 D.1 ApplicabilityandDefinitions ...................242 D.2 VerbatimCopying .........................243 D.3 CopyinginQuantity........................243 D.4 Modifications............................244 D.5 CombiningDocuments.......................246 D.6 CollectionsofDocuments .....................247 D.7 AggregationwithIndependentWorks...............247 D.8 Translation.............................247 D.9 Termination.............................248 D.10 FutureRevisionsofThisLicense .................248 D.11 Addendum:HowtoUseThisLicenseforYourDocuments...248 Contents Foreword v Preface vii ContributorList xiii 1 Thewayoftheprogram 1 1.1 ThePythonprogramminglanguage................ 1 1.2 Whatisaprogram? ........................ 3 1.3 Whatisdebugging? ........................ 4 1.4 Formalandnaturallanguages................... 6 1.5 Thefirstprogram.......................... 8 1.6 Glossary............................... 8 2 Variables,expressionsandstatements 11 2.1 Valuesandtypes.......................... 11 2.2 Variables............................... 12 2.3 Variablenamesandkeywords................... 13 2.4 Statements ............................. 14 2.5 Evaluatingexpressions....................... 15 2.6 Operatorsandoperands...................... 16
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索:
 输入关键字,在本站1000多万海量源码库中尽情搜索: