Read more
Klappentext This book is authorized for sale in Europe, Africa and the Middle East only and may not be exported. The content is materially different than products for other markets including the authorized U.S. counterpart of this title. Exportation of this book to another region without the Publisher's authorization may be illegal and a violation of the Publisher's rights. The Publisher may take legal action to enforce its rights. Inhaltsverzeichnis Preface iii Special Features xviii 1 Introduction 1 1.1 Computer Programs 2 1.2 The Anatomy of a Computer 3 CS1 Computers Are Everywhere 5 1.3 The Python Programming Language 5 1.4 Becoming Familiar with Your Programming Environment 6 PT1 Interactive Mode 8 PT2 Backup Copies 9 ST1 The Python Interpreter 10 1.5 Analyzing Your First Program 11 1.6 Errors 13 CE1 Misspelling Words 14 1.7 PROBLEM SOLVING: Algorithm Design 15 CS2 Data Is Everywhere 17 HT1 Describing an Algorithm with Pseudocode 18 WE1 Writing an Algorithm for Tiling a Floor 20 2 Programming with Numbers and Strings 23 2.1 Variables 24 Defining Variables 24 Number Types 26 Variable Names 27 Constants 28 Comments 29 CE1 Using Undefined Variables 30 Pt1 Choose Descriptive Variable Names 30 PT2 Do Not Use Magic Numbers 30 2.2 Arithmetic 31 Basic Arithmetic Operations 31 Powers 32 Floor Division and Remainder 32 Calling Functions 33 Mathematical Functions 35 CE2 Roundoff Errors 36 CE3 Unbalanced Parentheses 37 PT3 Use Spaces in Expressions 37 ST1 Other Ways to Import Modules 38 ST2 Combining Assignment and Arithmetic 38 ST3 Line Joining 38 2.3 PROBLEM SOLVING: First Do It By Hand 39 WE1 Computing Travel Time 40 2.4 Strings 41 The String Type 41 Concatenation and Repetition 42 Converting Between Numbers and Strings 43 Strings and Characters 44 String Methods 45 ST4 Character Values 46 ST5 Escape Sequences 47 CS1 International Alphabets and Unicode 47 2.5 Input and Output 48 User Input 48 Numerical Input 49 Formatted Output 50 PT4 Don't Wait to Convert 53 HT1 Writing Simple Programs 53 WE2 Computing the Cost of Stamps 56 CS2 Bugs in Silicon 58 2.6 GRAPHICS: Simple Drawings 58 Creating a Window 59 Lines and Polygons 60 Filled Shapes and Color 62 Ovals, Circles, and Text 64 HT2 GRAPHICS: Drawing Graphical Shapes 65 TOOLBOX 1 Symbolic Processing with SymPy 68 3 Decisions 73 3.1 The if Statement 74 CE1 Tabs 77 PT1 Avoid Duplication in Branches 78 ST1 Conditional Expressions 78 3.2 Relational Operators 79 CE2 Exact Comparison of Floating-Point Numbers 82 ST2 Lexicographic Ordering of Strings 82 HT1 Implementing an if Statement 83 WE1 Extracting the Middle 85 3.3 Nested Branches 87 PT2 Hand-Tracing 89 CS1 Dysfunctional Computerized Systems 90 3.4 Multiple Alternatives 91 TOOLBOX 1 Sending E-mail 93 3.5 PROBLEM SOLVING: Flowcharts 96 3.6 PROBLEM SOLVING: Test Cases 99 PT3 Make a Schedule and Make Time for Unexpected Problems 100 3.7 Boolean Variables and Operators 101 CE3 Confusing and and or Conditions 104 PT4 Readability 104 ST3 Chaining Relational Operators 105 ST4 Short-Circuit Evaluation of Boolean Operators 105 ST5 De Morgan's Law 106 3.8 Analyzing Strings 106 3.9 APPLICATION: Input Validation 110 ST6 Terminating a Program 112 ST7 Interactive Graphical Programs 112 CS2 Artificial Intelligence 113 WE2 GRAPHICS: Inters...