Practical Programming - An Introduction to Computer Science Using Python

时间:2022-09-07 11:48:22
【文件属性】:

文件名称:Practical Programming - An Introduction to Computer Science Using Python

文件大小:9.17MB

文件格式:PDF

更新时间:2022-09-07 11:48:22

Practical Programming Introduction Computer Python

Contents 1 Introduction 11 1.1 ProgramsandProgramming................ 13 1.2 AFewDefinitions...................... 14 1.3 WhattoInstall........................ 14 1.4 ForInstructors........................ 15 1.5 Summary........................... 16 2 Hello,Python 17 2.1 TheBigPicture ....................... 17 2.2 Expressions......................... 19 2.3 WhatIsaType?....................... 22 2.4 VariablesandtheAssignmentStatement........ 25 2.5 WhenThingsGoWrong .................. 29 2.6 FunctionBasics....................... 30 2.7 Built-inFunctions...................... 33 2.8 StyleNotes.......................... 34 2.9 Summary........................... 35 2.10 Exercises........................... 36 3 Strings 39 3.1 Strings............................ 39 3.2 EscapeCharacters ..................... 42 3.3 MultilineStrings....................... 43 3.4 Print.............................. 44 3.5 FormattedPrinting..................... 45 3.6 UserInput.......................... 46 3.7 Summary........................... 47 3.8 Exercises........................... 48 Prepared exclusively for Trieu Nguyen CONTENTS 8 4 Modules 50 4.1 ImportingModules ..................... 50 4.2 DefiningYourOwnModules................ 54 4.3 ObjectsandMethods.................... 60 4.4 PixelsandColors...................... 68 4.5 Testing............................ 70 4.6 StyleNotes.......................... 76 4.7 Summary........................... 77 4.8 Exercises........................... 78 5 Lists 81 5.1 ListsandIndices ...................... 81 5.2 ModifyingLists........................ 85 5.3 Built-inFunctionsonLists ................ 87 5.4 ProcessingListItems.................... 89 5.5 Slicing............................. 92 5.6 Aliasing............................ 94 5.7 ListMethods......................... 95 5.8 NestedLists......................... 97 5.9 OtherKindsofSequences................. 99 5.10 FilesasLists......................... 100 5.11 Comments.......................... 103 5.12 Summary........................... 105 5.13 Exercises........................... 105 6 MakingChoices 108 6.1 BooleanLogic ........................ 108 6.2 ifStatements......................... 118 6.3 StoringConditionals .................... 125 6.4 Summary........................... 126 6.5 Exercises........................... 127 7 Repetition 131 7.1 CountedLoops........................ 131 7.2 whileLoops.......................... 140 7.3 UserInputLoops...................... 148 7.4 ControllingLoops...................... 149 7.5 StyleNotes.......................... 153 7.6 Summary........................... 154 7.7 Exercises........................... 155 Reporterratum thiscopyis(P1.0printing,April2009) Prepared exclusively for Trieu Nguyen CONTENTS 9 8 FileProcessing 159 8.1 OneRecordperLine .................... 160 8.2 RecordswithMultipleFields................ 171 8.3 PositionalData ....................... 174 8.4 MultilineRecords...................... 177 8.5 LookingAhead........................ 179 8.6 WritingtoFiles........................ 181 8.7 Summary........................... 183 8.8 Exercises........................... 183 9 SetsandDictionaries 185 9.1 Sets.............................. 185 9.2 Dictionaries ......................... 190 9.3 InvertingaDictionary.................... 197 9.4 Summary........................... 198 9.5 Exercises........................... 199 10Algorithms 203 10.1 Searching........................... 204 10.2 Timing ............................ 211 10.3 Summary........................... 211 10.4 Exercises........................... 212 11SearchingandSorting 214 11.1 LinearSearch........................ 214 11.2 BinarySearch........................ 218 11.3 Sorting............................ 222 11.4 MoreEfficientSortingAlgorithms............. 228 11.5 Mergesort:AnNlog2NAlgorithm ............. 229 11.6 Summary........................... 233 11.7 Exercises........................... 234 12Construction 237 12.1 MoreonFunctions..................... 237 12.2 Exceptions.......................... 242 12.3 Testing............................ 249 12.4 Debugging.......................... 254 12.5 Patterns ........................... 256 12.6 Summary........................... 260 12.7 Exercises........................... 261 Reporterratum thiscopyis(P1.0printing,April2009) Prepared exclusively for Trieu Nguyen CONTENTS 10 13Object-OrientedProgramming 270 13.1 ClassColor.......................... 271 13.2 SpecialMethods....................... 276 13.3 MoreAboutdirandhelp.................. 278 13.4 ALittleBitofOOTheory.................. 280 13.5 ALongerExample...................... 288 13.6 Summary........................... 293 13.7 Exercises........................... 293 14GraphicalUserInterfaces 294 14.1 TheTkinterModule..................... 295 14.2 BasicGUIConstruction .................. 296 14.3 Models,Views,andControllers.............. 301 14.4 Style.............................. 307 14.5 AFewMoreWidgets..................... 312 14.6 Object-OrientedGUIs.................... 316 14.7 Summary........................... 317 14.8 Exercises........................... 318 15Databases 321 15.1 TheBigPicture ....................... 321 15.2 FirstSteps.......................... 323 15.3 RetrievingData ....................... 327 15.4 UpdatingandDeleting................... 330 15.5 Transactions......................... 331 15.6 UsingNULLforMissingData............... 333 15.7 UsingJoinstoCombineTables.............. 334 15.8 KeysandConstraints.................... 339 15.9 AdvancedFeatures..................... 341 15.10Summary........................... 346 15.11Exercises........................... 347 A Bibliography 351 Index 353 Reporterratum


网友评论