100% found this document useful (1 vote)
87 views

(eBook PDF) Practice of Computing Using Python, The 3rd Edition download

The document is a promotional listing for various eBooks related to Python programming and other subjects, including titles like 'Practice of Computing Using Python' and 'Introduction to Programming Using Python.' It provides links to download these eBooks from the website ebookluna.com. The content also includes a detailed table of contents for the 'Practice of Computing Using Python' eBook, outlining chapters and topics covered.

Uploaded by

drishendowub
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
87 views

(eBook PDF) Practice of Computing Using Python, The 3rd Edition download

The document is a promotional listing for various eBooks related to Python programming and other subjects, including titles like 'Practice of Computing Using Python' and 'Introduction to Programming Using Python.' It provides links to download these eBooks from the website ebookluna.com. The content also includes a detailed table of contents for the 'Practice of Computing Using Python' eBook, outlining chapters and topics covered.

Uploaded by

drishendowub
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

(eBook PDF) Practice of Computing Using Python,

The 3rd Edition download

https://ebookluna.com/product/ebook-pdf-practice-of-computing-
using-python-the-3rd-edition/

Download full version ebook from https://ebookluna.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookluna.com
to discover even more!

(eBook PDF) Introduction to Programming Using Python An 1

https://ebookluna.com/product/ebook-pdf-introduction-to-programming-using-
python-an-1/

(eBook PDF) Numerical Analysis: Mathematics of Scientific Computing 3rd

https://ebookluna.com/product/ebook-pdf-numerical-analysis-mathematics-of-
scientific-computing-3rd/

(eBook PDF) The Practice of Creative Writings 3rd Edition

https://ebookluna.com/product/ebook-pdf-the-practice-of-creative-
writings-3rd-edition/

The Physics of Computing 1st Edition Marilyn Wolf - eBook PDF

https://ebookluna.com/download/the-physics-of-computing-ebook-pdf/
(eBook PDF) The Doctor of Nursing Practice Essentials 3rd Edition

https://ebookluna.com/product/ebook-pdf-the-doctor-of-nursing-practice-
essentials-3rd-edition/

(eBook PDF) Python Programming in Context 3rd Edition

https://ebookluna.com/product/ebook-pdf-python-programming-in-context-3rd-
edition/

Python Programming in Context, 3rd Edition (eBook PDF)

https://ebookluna.com/product/python-programming-in-context-3rd-edition-
ebook-pdf/

(eBook PDF) The Speaker: The Tradition and Practice of Public Speaking 3rd

https://ebookluna.com/product/ebook-pdf-the-speaker-the-tradition-and-
practice-of-public-speaking-3rd/

(eBook PDF) The Nurse, The Math, The Meds: Drug Calculations Using
Dimensional Analysis 3rd Edition

https://ebookluna.com/product/ebook-pdf-the-nurse-the-math-the-meds-drug-
calculations-using-dimensional-analysis-3rd-edition/
THE PRACTICE OF COMPUTING USING

3RD EDITION

WILLIAM RICHARD
PUNCH • ENBODY
C O N T E N T S

VIDEONOTES xxiv
PREFACE xxv
PREFACE TO THE SECOND EDITION xxix
1.0.1 Data Manipulation xxx
1.0.2 Problem Solving and Case Studies xxx
1.0.3 Code Examples xxx
1.0.4 Interactive Sessions xxxi
1.0.5 Exercises and Programming Projects xxxi
1.0.6 Self-Test Exercises xxxi
1.0.7 Programming Tips xxxi

PART 1 THINKING ABOUT COMPUTING 1


Chapter 0 The Study of Computer Science 3
0.1 Why Computer Science? 3
0.1.1 Importance of Computer Science 3
0.1.2 Computer Science Around You 4
0.1.3 Computer “Science” 4
0.1.4 Computer Science Through Computer Programming 6
0.2 The Difficulty and Promise of Programming 6
0.2.1 Difficulty 1: Two Things at Once 6
0.2.2 Difficulty 2: What Is a Good Program? 9
0.2.3 The Promise of a Computer Program 10
0.3 Choosing a Computer Language 11
0.3.1 Different Computer Languages 11
0.3.2 Why Python? 11
0.3.3 Is Python the Best Language? 13
0.4 What Is Computation? 13
0.5 What Is a Computer? 13

vii
viii CONTENTS

0.5.1 Computation in Nature 14


0.5.2 The Human Computer 17
0.6 The Modern, Electronic Computer 18
0.6.1 It’s the Switch! 18
0.6.2 The Transistor 19
0.7 A High-Level Look at a Modern Computer 24
0.8 Representing Data 26
0.8.1 Binary Data 26
0.8.2 Working with Binary 27
0.8.3 Limits 28
0.8.4 Representing Letters 29
0.8.5 Representing Other Data 30
0.8.6 What Does a Number Represent? 31
0.8.7 How to Talk About Quantities of Data 32
0.8.8 How Much Data Is That? 32
0.9 Overview of Coming Chapters 34

P A R T 2 S TA RT I N G T O P R O G R A M 35
Chapter 1 Beginnings 37
1.1 Practice, Practice, Practice 37
1.2 QuickStart, the Circumference Program 38
1.2.1 Examining the Code 40
1.3 An Interactive Session 42
1.4 Parts of a Program 43
1.4.1 Modules 43
1.4.2 Statements and Expressions 43
1.4.3 Whitespace 45
1.4.4 Comments 46
1.4.5 Special Python Elements: Tokens 46
1.4.6 Naming Objects 48
1.4.7 Recommendations on Naming 49
1.5 Variables 49
1.5.1 Variable Creation and Assignment 50
1.6 Objects and Types 53
1.6.1 Numbers 55
1.6.2 Other Built-In Types 57
1.6.3 Object Types: Not Variable Types 58
1.6.4 Constructing New Values 60
CONTENTS ix

1.7 Operators 61
1.7.1 Integer Operators 61
1.7.2 Floating-Point Operators 64
1.7.3 Mixed Operations 64
1.7.4 Order of Operations and Parentheses 65
1.7.5 Augmented Assignment Operators: A Shortcut! 66
1.8 Your First Module, Math 68
1.9 Developing an Algorithm 69
1.9.1 New Rule—Testing 73
1.10 Visual Vignette: Turtle Graphics 74
1.11 What’s Wrong with My Code? 75
Chapter 2 Control 87
2.1 QuickStart Control 87
2.1.1 Selection 87
2.1.2 Booleans for Decisions 89
2.1.3 The if Statement 89
2.1.4 Example: What Lead Is Safe in Basketball? 92
2.1.5 Repetition 96
2.1.6 Example: Finding Perfect Numbers 100
2.1.7 Example: Classifying Numbers 105
2.2 In-Depth Control 109
2.2.1 True and False: Booleans 109
2.2.2 Boolean Variables 110
2.2.3 Relational Operators 110
2.2.4 Boolean Operators 115
2.2.5 Precedence 116
2.2.6 Boolean Operators Example 117
2.2.7 Another Word on Assignments 120
2.2.8 The Selection Statement for Decisions 122
2.2.9 More on Python Decision Statements 122
2.2.10 Repetition: the while Statement 126
2.2.11 Sentinel Loop 136
2.2.12 Summary of Repetition 136
2.2.13 More on the for Statement 137
2.2.14 Nesting 140
2.2.15 Hailstone Sequence Example 142
2.3 Visual Vignette: Plotting Data with Pylab 143
2.3.1 First Plot and Using a List 144
2.3.2 More Interesting Plot: A Sine Wave 145
x CONTENTS

2.4 Computer Science Perspectives: Minimal Universal Computing 147


2.4.1 Minimal Universal Computing 147
2.5 What’s Wrong with My Code? 148
Chapter 3 Algorithms and Program Development 161
3.1 What Is an Algorithm? 161
3.1.1 Example Algorithms 162
3.2 Algorithm Features 163
3.2.1 Algorithm versus Program 163
3.2.2 Qualities of an Algorithm 165
3.2.3 Can We Really Do All That? 167
3.3 What Is a Program? 167
3.3.1 Readability 167
3.3.2 Robust 171
3.3.3 Correctness 172
3.4 Strategies for Program Design 173
3.4.1 Engage and Commit 173
3.4.2 Understand, Then Visualize 174
3.4.3 Think Before You Program 175
3.4.4 Experiment 175
3.4.5 Simplify 175
3.4.6 Stop and Think 177
3.4.7 Relax: Give Yourself a Break 177
3.5 A Simple Example 177
3.5.1 Build the Skeleton 178
3.5.2 Output 178
3.5.3 Input 179
3.5.4 Doing the Calculation 181

P A R T 3 D AT A S T R U C T U R E S A N D F U N C T I O N S 187
Chapter 4 Working with Strings 189
4.1 The String Type 190
4.1.1 The Triple-Quote String 190
4.1.2 Nonprinting Characters 191
4.1.3 String Representation 191
4.1.4 Strings as a Sequence 192
4.1.5 More Indexing and Slicing 193
4.1.6 Strings Are Iterable 198
CONTENTS xi

4.2 String Operations 199


4.2.1 Concatenation (+) and Repetition (*) 199
4.2.2 Determining When + Indicates Addition or
Concatenation? 200
4.2.3 Comparison Operators 201
4.2.4 The in Operator 202
4.2.5 String Collections Are Immutable 203
4.3 A Preview of Functions and Methods 205
4.3.1 A String Method 205
4.3.2 Determining Method Names and Method Arguments 208
4.3.3 String Methods 210
4.3.4 String Functions 210
4.4 Formatted Output for Strings 211
4.4.1 Descriptor Codes 212
4.4.2 Width and Alignment Descriptors 213
4.4.3 Floating-Point Precision Descriptor 214
4.5 Control and Strings 215
4.6 Working with Strings 218
4.6.1 Example: Reordering a Person’s Name 218
4.6.2 Palindromes 220
4.7 More String Formatting 223
4.8 Unicode 226
4.9 A GUI to Check a Palindrome 228
4.10 What’s Wrong with My Code? 232
Chapter 5 Functions—QuickStart 245
5.1 What Is a Function? 245
5.1.1 Why Have Functions? 246
5.2 Python Functions 247
5.3 Flow of Control with Functions 250
5.3.1 Function Flow in Detail 251
5.3.2 Parameter Passing 251
5.3.3 Another Function Example 253
5.3.4 Function Example: Area of a Triangle 254
5.3.5 Functions Calling Functions 258
5.3.6 When to Use a Function 259
5.3.7 What If There Is No Return Statement? 260
5.3.8 What If There Are Multiple Return Statements? 260
xii CONTENTS

5.4 Visual Vignette: Turtle Flag 261


5.5 What’s Wrong with My Code? 262
Chapter 6 Files and Exceptions I 271
6.1 What Is a File? 271
6.2 Accessing Files: Reading Text Files 271
6.2.1 What’s Really Happening? 272
6.3 Accessing Files: Writing Text Files 273
6.4 Reading and Writing Text Files in a Program 274
6.5 File Creation and Overwriting 275
6.5.1 Files and Functions Example: Word Puzzle 276
6.6 First Cut, Handling Errors 282
6.6.1 Error Names 283
6.6.2 The try-except Construct 283
6.6.3 try-except Flow of Control 284
6.6.4 Exception Example 285
6.7 Example: Counting Poker Hands 288
6.7.1 Program to Count Poker Hands 291
6.8 GUI to Count Poker Hands 299
6.8.1 Count Hands Function 300
6.8.2 The Rest of the GUI Code 302
6.9 Error Check Float Input 304
6.10 What’s Wrong with My Code? 304
Chapter 7 Lists and Tuples 311
7.1 What Is a List? 311
7.2 What You Already Know How To Do With Lists 313
7.2.1 Indexing and Slicing 314
7.2.2 Operators 315
7.2.3 Functions 317
7.2.4 List Iteration 318
7.3 Lists Are Different than Strings 319
7.3.1 Lists Are Mutable 319
7.3.2 List Methods 320
7.4 Old and New Friends: Split and Other Functions and Methods 325
7.4.1 Split and Multiple Assignment 325
7.4.2 List to String and Back Again, Using join 326
7.4.3 The Sorted Function 327
CONTENTS xiii

7.5 Working with Some Examples 328


7.5.1 Anagrams 328
7.5.2 Example: File Analysis 334
7.6 Mutable Objects and References 340
7.6.1 Shallow versus Deep Copy 345
7.6.2 Mutable versus Immutable 349
7.7 Tuples 350
7.7.1 Tuples from Lists 352
7.7.2 Why Tuples? 353
7.8 Lists: The Data Structure 353
7.8.1 Example Data Structure 354
7.8.2 Other Example Data Structures 355
7.9 Algorithm Example: U.S. EPA Automobile Mileage Data 355
7.9.1 CSV Module 365
7.10 Visual Vignette: Plotting EPA Data 366
7.11 List Comprehension 368
7.11.1 Comprehensions, Expressions, and the Ternary
Operator 370
7.12 Visual Vignette: More Plotting 370
7.12.1 Pylab Arrays 371
7.12.2 Plotting Trigonometric Functions 373
7.13 GUI to Find Anagrams 374
7.13.1 Function Model 374
7.13.2 Controller 375
7.14 What’s Wrong with My Code? 377
Chapter 8 More on Functions 395
8.1 Scope 395
8.1.1 Arguments, Parameters, and Namespaces 397
8.1.2 Passing Mutable Objects 399
8.1.3 Returning a Complex Object 401
8.1.4 Refactoring evens 403
8.2 Default Values and Parameters as Keywords 404
8.2.1 Example: Default Values and Parameter Keywords 405
8.3 Functions as Objects 407
8.3.1 Function Annotations 408
8.3.2 Docstrings 409
xiv CONTENTS

8.4 Example: Determining a Final Grade 410


8.4.1 The Data 410
8.4.2 The Design 410
8.4.3 Function: weighted_grade 411
8.4.4 Function: parse_line 411
8.4.5 Function: main 412
8.4.6 Example Use 413
8.5 Pass “by Value” or “by Reference” 413
8.6 What’s Wrong with My Code? 414
Chapter 9 Dictionaries and Sets 423
9.1 Dictionaries 423
9.1.1 Dictionary Example 424
9.1.2 Python Dictionaries 425
9.1.3 Dictionary Indexing and Assignment 425
9.1.4 Operators 426
9.1.5 Ordered Dictionaries 431
9.2 Word Count Example 432
9.2.1 Count Words in a String 432
9.2.2 Word Frequency for Gettysburg Address 433
9.2.3 Output and Comments 437
9.3 Periodic Table Example 438
9.3.1 Working with CSV Files 439
9.3.2 Algorithm Overview 441
9.3.3 Functions for Divide and Conquer 441
9.4 Sets 445
9.4.1 History 445
9.4.2 What’s in a Set? 445
9.4.3 Python Sets 446
9.4.4 Methods, Operators, and Functions for Python Sets 447
9.4.5 Set Methods 447
9.5 Set Applications 452
9.5.1 Relationship between Words of Different 452
9.5.2 Output and Comments 456
9.6 Scope: The Full Story 456
9.6.1 Namespaces and Scope 457
9.6.2 Search Rule for Scope 457
9.6.3 Local 457
9.6.4 Global 458
9.6.5 Built-Ins 462
9.6.6 Enclosed 463
CONTENTS xv

9.7 Using zip to Create Dictionaries 464


9.8 Dictionary and Set Comprehensions 465
9.9 Visual Vignette: Bar Graph of Word Frequency 466
9.9.1 Getting the Data Right 466
9.9.2 Labels and the xticks Command 467
9.9.3 Plotting 467
9.10 GUI to Compare Files 468
9.10.1 Controller and View 469
9.10.2 Function Model 471
9.11 What’s Wrong with My Code? 473
Chapter 10 More Program Development 483
10.1 Introduction 483
10.2 Divide and Conquer 483
10.2.1 Top-Down Refinement 484
10.3 The Breast Cancer Classifier 484
10.3.1 The Problem 484
10.3.2 The Approach: Classification 485
10.3.3 Training and Testing the Classifier 485
10.3.4 Building the Classifier 485
10.4 Designing the Classifier Algorithm 487
10.4.1 Divided, now Conquer 490
10.4.2 Data Structures 491
10.4.3 File Format 491
10.4.4 The make_training_set Function 492
10.4.5 The make_test_set Function 496
10.4.6 The train_classifier Function 497
10.4.7 train_classifier, Round 2 499
10.4.8 Testing the Classifier on New Data 502
10.4.9 The report_results Function 506
10.5 Running the Classifier on Full Data 508
10.5.1 Training versus Testing 508
10.6 Other Interesting Problems 512
10.6.1 Tag Clouds 512
10.6.2 S&P 500 Predictions 514
10.6.3 Predicting Religion with Flags 517
10.7 GUI to Plot the Stock Market 519
10.7.1 Function Model 519
10.7.2 Controller and View 521
xvi CONTENTS

P A R T 4 C L A S S E S , M A K I N G Y O U R O W N D AT A S T R U C T U R E S
AND ALGORITHMS 527
Chapter 11 Introduction to Classes 529
11.1 QuickStart: Simple Student Class 529
11.2 Object-Oriented Programming 530
11.2.1 Python Is Object-Oriented! 530
11.2.2 Characteristics of OOP 531
11.3 Working with OOP 531
11.3.1 Class and Instance 531
11.4 Working with Classes and Instances 532
11.4.1 Built-In Class and Instance 532
11.4.2 Our First Class 534
11.4.3 Changing Attributes 536
11.4.4 The Special Relationship Between an Instance and
Class: instance-of 537
11.5 Object Methods 540
11.5.1 Using Object Methods 540
11.5.2 Writing Methods 541
11.5.3 The Special Argument self 542
11.5.4 Methods Are the Interface to a Class Instance 544
11.6 Fitting into the Python Class Model 545
11.6.1 Making Programmer-Defined Classes 545
11.6.2 A Student Class 545
11.6.3 Python Standard Methods 546
11.6.4 Now There Are Three: Class Designer, Programmer,
and User 550
11.7 Example: Point Class 551
11.7.1 Construction 553
11.7.2 Distance 553
11.7.3 Summing Two Points 553
11.7.4 Improving the Point Class 554
11.8 Python and OOP 558
11.8.1 Encapsulation 558
11.8.2 Inheritance 559
11.8.3 Polymorphism 559
11.9 Python and Other OOP Languages 559
11.9.1 Public versus Private 559
11.9.2 Indicating Privacy Using Double Underscores (__) 560
CONTENTS xvii

11.9.3 Python’s Philosophy 561


11.9.4 Modifying an Instance 562
11.10 What’s Wrong with My Code? 562
Chapter 12 More on Classes 571
12.1 More About Class Properties 571
12.1.1 Rational Number (Fraction) Class Example 572
12.2 How Does Python Know? 574
12.2.1 Classes, Types, and Introspection 574
12.2.2 Remember Operator Overloading 577
12.3 Creating Your Own Operator Overloading 577
12.3.1 Mapping Operators to Special Methods 578
12.4 Building the Rational Number Class 581
12.4.1 Making the Class 581
12.4.2 Review Fraction Addition 583
12.4.3 Back to Adding Fractions 586
12.4.4 Equality and Reducing Rationals 590
12.4.5 Divide and Conquer at Work 593
12.5 What Doesn’t Work (Yet) 593
12.5.1 Introspection 594
12.5.2 Repairing int + Rational Errors 596
12.6 Inheritance 598
12.6.1 The “Find the Attribute” Game 599
12.6.2 Using Inheritance 602
12.6.3 Example: The Standard Model 603
12.7 What’s Wrong with My Code? 608
Chapter 13 Program Development with Classes 615
13.1 Predator–Prey Problem 615
13.1.1 The Rules 616
13.1.2 Simulation Using Object-Oriented Programming 617
13.2 Classes 617
13.2.1 Island Class 617
13.2.2 Predator and Prey, Kinds of Animals 619
13.2.3 Predator and Prey Classes 622
13.2.4 Object Diagram 623
13.2.5 Filling the Island 623
13.3 Adding Behavior 626
13.3.1 Refinement: Add Movement 626
13.3.2 Refinement: Time Simulation Loop 629
xviii CONTENTS

13.4 Refinement: Eating, Breeding, and Keeping Time 630


13.4.1 Improved Time Loop 631
13.4.2 Breeding 634
13.4.3 Eating 636
13.4.4 The Tick of the Clock 637
13.5 Refinement: How Many Times to Move? 638
13.6 Visual Vignette: Graphing Population Size 639

PART 5 BEING A BETTER PROGRAMMER 643


Chapter 14 Files and Exceptions II 645
14.1 More Details on Files 645
14.1.1 Other File Access Methods, Reading 647
14.1.2 Other File Access Methods, Writing 649
14.1.3 Universal New Line Format 651
14.1.4 Moving Around in a File 652
14.1.5 Closing a File 654
14.1.6 The with Statement 654
14.1.7 Text File Encodings; Unicode 655
14.2 CSV Files 656
14.2.1 CSV Module 657
14.2.2 CSV Reader 658
14.2.3 CSV Writer 659
14.2.4 Example: Update Some Grades 659
14.3 Module: os 661
14.3.1 Directory (Folder) Structure 662
14.3.2 os Module Functions 663
14.3.3 os Module Example 665
14.4 More on Exceptions 667
14.4.1 Basic Exception Handling 668
14.4.2 A Simple Example 669
14.4.3 Events 671
14.4.4 A Philosophy Concerning Exceptions 672
14.5 Exception: else and finally 673
14.5.1 finally and with 673
14.5.2 Example: Refactoring the Reprompting of a File Name 673
14.6 More on Exceptions 675
14.6.1 Raise 675
14.6.2 Create Your Own 676
14.7 Example: Password Manager 677
CONTENTS xix

Chapter 15 Recursion: Another Control Mechanism 687


15.1 What Is Recursion? 687
15.2 Mathematics and Rabbits 689
15.3 Let’s Write Our Own: Reversing a String 692
15.4 How Does Recursion Actually Work? 694
15.4.1 Stack Data Structure 695
15.4.2 Stacks and Function Calls 697
15.4.3 A Better Fibonacci 699
15.5 Recursion in Figures 700
15.5.1 Recursive Tree 700
15.5.2 Sierpinski Triangles 702
15.6 Recursion to Non-recursion 703
15.7 GUI for Turtle Drawing 704
15.7.1 Using Turtle Graphics to Draw 704
15.7.2 Function Model 705
15.7.3 Controller and View 706
Chapter 16 Other Fun Stuff with Python 709
16.1 Numbers 709
16.1.1 Fractions 710
16.1.2 Decimal 714
16.1.3 Complex Numbers 718
16.1.4 Statistics Module 720
16.1.5 Random Numbers 722
16.2 Even More on Functions 724
16.2.1 Having a Varying Number of Parameters 725
16.2.2 Iterators and Generators 728
16.2.3 Other Functional Programming Ideas 733
16.2.4 Some Functional Programming Tools 734
16.2.5 Decorators: Functions Calling Functions 736
16.3 Classes 741
16.3.1 Properties 742
16.3.2 Serializing an Instance: pickle 745
16.4 Other Things in Python 748
16.4.1 Data Types 748
16.4.2 Built-in Modules 748
16.4.3 Modules on the Internet 749
Chapter 17 The End, or Perhaps the Beginning 751
xx CONTENTS

APPENDICES 753
Appendix A Getting and Using Python 753
A.1 About Python 753
A.1.1 History 753
A.1.2 Python 3 753
A.1.3 Python Is Free and Portable 754
A.1.4 Installing Anaconda 756
A.1.5 Starting Our Python IDE: Spyder 756
A.1.6 Working with Python 757
A.1.7 Making a Program 760
A.2 The IPython Console 762
A.2.1 Anatomy of an iPython Session 763
A.2.2 Your Top Three iPython Tips 764
A.2.3 Completion and the Tab Key 764
A.2.4 The ? Character 766
A.2.5 More iPython Tips 766
A.3 Some Conventions for This Book 769
A.3.1 Interactive Code 770
A.3.2 Program: Written Code 770
A.3.3 Combined Program and Output 770
A.4 Summary 771
Appendix B Simple Drawing with Turtle Graphics 773
B.0.1 What Is a Turtle? 773
B.0.2 Motion 775
B.0.3 Drawing 775
B.0.4 Color 777
B.0.5 Drawing with Color 779
B.0.6 Other Commands 781
B.1 Tidbits 783
B.1.1 Reset/Close the Turtle Window 783
Appendix C What’s Wrong with My Code? 785
C.1 It’s Your Fault! 785
C.1.1 Kinds of Errors 785
C.1.2 “Bugs” and Debugging 787
C.2 Debugging 789
C.2.1 Testing for Correctness 789
C.2.2 Probes 789
C.2.3 Debugging with Spyder Example 1 789
C.2.4 Debugging Example 1 Using print() 793
CONTENTS xxi

C.2.5 Debugging with Spyder Example 2 794


C.2.6 More Debugging Tips 802
C.3 More about Testing 803
C.3.1 Testing Is Hard! 804
C.3.2 Importance of Testing 805
C.3.3 Other Kinds of Testing 805
C.4 What’s Wrong with My Code? 805
C.4.1 Chapter 1: Beginnings 805
C.4.2 Chapter 2: Control 807
C.4.3 Chapter 4: Strings 808
C.4.4 Chapter 5: Functions 809
C.4.5 Chapter 6: Files and Exceptions 810
C.4.6 Chapter 7: Lists and Tuples 811
C.4.7 Chapter 8: More Functions 812
C.4.8 Chapter 9: Dictionaries 813
C.4.9 Chapter 11: Classes I 814
C.4.10 Chapter 12: Classes II 815
Appendix D Pylab: A Plotting and Numeric Tool 817
D.1 Plotting 817
D.2 Working with pylab 818
D.2.1 Plot Command 818
D.2.2 Colors, Marks, and Lines 819
D.2.3 Generating X-Values 819
D.2.4 Plot Properties 820
D.2.5 Tick Labels 821
D.2.6 Legend 822
D.2.7 Bar Graphs 824
D.2.8 Histograms 824
D.2.9 Pie Charts 825
D.2.10 How Powerful Is pylab? 826
Appendix E Quick Introduction to Web-based User Interfaces 829
E.0.1 MVC Architecture 830
E.1 Flask 830
E.2 QuickStart Flask, Hello World 831
E.2.1 What Just Happened? 832
E.2.2 Multiple Routes 833
E.2.3 Stacked Routes, Passing Address Arguments 835
E.3 Serving Up Real HTML Pages 836
E.3.1 A Little Bit of HTML 836
E.3.2 HTML Tags 836
xxii CONTENTS

E.3.3 Flask Returning Web Pages 838


E.3.4 Getting Arguments into Our Web Pages 839
E.4 Active Web Pages 841
E.4.1 Forms in wtforms 841
E.4.2 A Good Example Goes a Long Way 842
E.4.3 Many Fields Example 847
E.5 Displaying and Updating Images 852
E.6 Odds and Ends 857
Appendix F Table of UTF-8 One Byte Encodings 859
Appendix G Precedence 861
Appendix H Naming Conventions 863
H.1 Python Style Elements 864
H.2 Naming Conventions 864
H.2.1 Our Added Naming Conventions 864
H.3 Other Python Conventions 865
Appendix I Check Yourself Solutions 867
I.1 Chapter 1 867
Variables and Assignment 867
Types and Operators 867
I.2 Chapter 2 868
Basic Control Check 868
Loop Control Check 868
More Control Check 868
for and range Check 868
I.3 Chapter 4 869
Slicing Check 869
String Comparison Check 869
I.4 Chapter 5 869
Simple Functions Check 869
I.5 Chapter 6 869
Exception Check 869
Function Practice with Strings 870
I.6 Chapter 7 870
Basic Lists Check 870
Lists and Strings Check 870
Mutable List Check 870
CONTENTS xxiii

I.7 Chapter 8 870


Passing Mutables Check 870
More on Functions Check 871
I.8 Chapter 9 871
Dictionary Check 871
Set Check 871
I.9 Chapter 11 871
Basic Classes Check 871
Defining Special Methods 871
I.10 Chapter 12 872
Check Defining Your Own Operators 872
I.11 Chapter 14 872
Basic File Operations 872
Basic Exception Control 872
INDEX 873
V I D E O N O T E S

VideoNote 0.1 Getting Python 13
VideoNote 1.1 Simple Arithmetic 64
VideoNote 1.2 Solving Your First Problem 73
VideoNote 2.1 Simple Control 96
VideoNote 2.2 Nested Control 140
VideoNote 3.1 Algorithm Decomposition 177
VideoNote 3.2 Algorithm Development 185
VideoNote 4.1 Playing with Strings 210
VideoNote 4.2 String Formatting 214
VideoNote 5.1 Simple Functions 251
VideoNote 5.2 Problem Design Using Functions 261
VideoNote 6.1 Reading Files 272
VideoNote 6.2 Simple Exception Handling 285
VideoNote 7.1 List Operations 327
VideoNote 7.2 List Application 349
VideoNote 8.1 More on Parameters 405
VideoNote 9.1 Using a Dictionary 437
VideoNote 9.2 More Dictionaries 465
VideoNote 10.1 Program Development: Tag Cloud 512
VideoNote 11.1 Designing a Class 545
VideoNote 11.2 Improving a Class 554
VideoNote 12.1 Augmenting a Class 593
VideoNote 12.2 Create a Class 596
VideoNote 13.1 Improve Simulation 623
VideoNote 14.1 Dictionary Exceptions 669
VideoNote 15.1 Recursion 692
VideoNote 16.1 Properties 742

xxiv
Discovering Diverse Content Through
Random Scribd Documents
“But it struck six,” said the puzzled Elizabeth Ann.

“Now for pity’s sake, don’t tell that child about ship’s time to-
night,” begged Aunt Grace. “I’ve been married to your Uncle Hiram
for fifteen years,” she added, turning to Elizabeth Ann, “and I can’t
make head or tail of his bells. I go by my good Christian clock, and I
say it’s seven o’clock when it is seven o’clock; six bells will never
mean seven o’clock to me.”

Elizabeth Ann, before she went to bed was as completely tangled


up about time as a girl could well be. It seemed, for Uncle Hiram
told her so while Aunt Grace was giving Doris a hot bath and putting
her to bed—rather into her bunk—that on board a ship the half
hours are very important. The ship’s clock strikes for them all. And
Uncle Hiram showed Elizabeth Ann, using his beautiful mahogany
clock which was in what he called “the first cabin” (and that was the
parlor) how the time was told off, starting at midnight.

“One bell is half-past twelve,” explained Uncle Hiram. “Two bells is


one o’clock; three bells is half-past one, and so on, around the clock.
It’s easy enough to understand, once you’re used to it, but your
Aunt Grace never would bother to learn it. She says she went by
land time so long that she can’t learn any new way of telling time.”

“I don’t think it is easy,” Elizabeth Ann said honestly, “and it does


mix me up. But I am going to learn it. Ted and Lansing know lots of
things I don’t, and I am going to learn something to surprise them.”

“Don’t try to learn it all at once,” advised Uncle Hiram kindly. “Take
things easy—you’ll have all winter to learn ship’s time in, and I will
help you. There’s your Aunt Grace calling you now.”

Aunt Grace wanted Elizabeth Ann to take her bath, and after
peeping into the kitchen and seeing that Tony was asleep on a small
round rug quite as though he felt at home there, Elizabeth Ann
climbed the ladder up to the pretty blue and white bathroom and
had her bath. Three minutes after that she was fast asleep, for no
matter how exciting it might be to sleep in a bunk, no little girl who
had traveled more than two hundred miles in one day could hope to
keep awake very long after she had gotten into such a nice soft bed.

It was fortunate that the next day there was no school—perhaps


Uncle Hiram had arranged things purposely so that Elizabeth Ann
and Doris should reach the farm one day before school opened. He
must have known that there would be many things they wanted to
see. The farm belonged to Aunt Grace and she had lived on it all her
life, she told the two little girls, who insisted on drying the dishes for
her the next morning.

“Your Uncle Hiram,” said Aunt Grace, and while of course he was
Doris’s uncle Elizabeth Ann felt as though he might be her uncle “a
little bit” as she said, for Doris was her cousin. “Your Uncle Hiram
was on a sailing vessel for forty years. It’s no wonder he can’t bear
to get away from the sea. But when he retired, he came back to
Gardner, where he lived when he was a boy, and we planned to be
married. I’m twenty years younger than he is and I didn’t want to
give up this farm—in fact I’d promised my mother and father to
always live here. Your uncle would have liked to live nearer the
ocean, I think, but he was very nice about it. He had some money
saved and he said he’d build us a house to live in, if I would let him
build the kind of house he liked. So he built this ship and I had the
tenant farmer move in the old farm house and we’ve been right
happy. Plenty of people think we’re crazy to live in a place that is
part ship and part house, but there are some things I like about it.”

“I think it is lovely,” declared Elizabeth Ann loyally. “I like to go up


and down ladders; and I like to sleep in a bunk.”

“Well, I like the deck, myself,” Aunt Grace explained. “It’s the best
place to dry clothes you ever did see. And in summer we have a
awning stretched over part of it and have chairs out there and it is
fine—there’s always a breeze. Some folks call it the roof, of course,
but your Uncle Hiram likes me to say ‘deck’ and I always do.”
And after the dishes were dried and put away, Aunt Grace took
Elizabeth Ann and Doris up to see the deck. It was scrubbed to a
shining whiteness, and there was a railing all around, just as there
would be on a ship, so that no one could fall off. They could see far
over the fields, and Aunt Grace pointed out the farm house where
the tenant farmer lived and even the chimneys of the house on the
next farm.

“Can we see the school from here?” asked Elizabeth Ann, who was
just the least bit anxious over the idea of going to a new school.
CHAPTER VII

SCHOOL NEWS

“See the school?” echoed Aunt Grace. “My dear child, of course
you can’t see the school; why it’s fully three miles from here, on the
other side of that section of woods. You have to walk half a mile to
get the bus.”

Elizabeth Ann hadn’t heard about the bus, and neither had Doris.

“You’re going to a consolidated school,” explained Aunt Grace.


“When I was a little girl they didn’t have them—we went to a little
school house near this farm. There was only one room, and my older
sister taught all the grades. But now they have combined a number
of these small schools into one large one. A bus goes through the
country gathering up the scholars, and in that way one school
building can be made to do the work of six or seven one-room
buildings.”

“Why doesn’t the bus come and get us right here?” Doris asked.

That was almost the first question she had asked and Aunt Grace
told her she was glad to hear her voice.

“The bus couldn’t go round to every farm—it would take too long,”
Aunt Grace said. “So the pupils gather in certain places where the
bus driver knows they’ll be, and he picks them up in groups. You
and Elizabeth Ann and the other children who live around here, have
to walk to the nearest cross-roads—your uncle will tell you what time
the bus passes there and what time you have to leave the house. If
there’s a bad storm or it rains too hard, he will take you in the car as
far as the cross-roads; but your Uncle Doctor wrote to tell me that
he wanted both of you to walk whenever it is possible.”

Elizabeth Ann liked to walk and Doris didn’t. But everyone did as
Uncle Doctor directed, always.

“Then we can take our lunch to school, can’t we?” suggested


Elizabeth Ann.

“Why you’ll have to take your lunch,” Aunt Grace replied. “I believe
some of the teachers make hot soup in the winter, but there is no
place where you can buy anything to eat. The consolidated school is
right in the country; there was some talk of building it in Gardner,
but they couldn’t agree on a plot of ground for it. You’ll both be
country girls if you live on a farm all winter, and go to a country
school.”

Elizabeth Ann and Doris had always wanted to take their lunches
to school. In Seabridge, Doris came home at noon to lunch, and
Elizabeth Ann had done that, too, wherever she went to school.
Even at Aunt Ida’s school, they had gone to Aunt Ida’s house for
lunch—her house was next door to the school.

“I think it will be more fun to carry our lunches,” said Elizabeth


Ann. “That is, if it won’t be too much trouble for you, Aunt Grace,”
she added.

Elizabeth Ann said “Aunt Grace” because Doris did, and now Aunt
Grace told her a surprising thing.

“I’ll be glad to put up lunches,” she declared. “I always wanted a


little girl or two of my own to work for; and it’s nice to hear you call
me ‘Aunt,’ Elizabeth Ann. You know you are distantly related to Uncle
Hiram.”

“Doris’s Uncle Hiram?” asked Elizabeth Ann.


“Yes,” Aunt Grace smiled a little. “Don’t ask me how it is, but I
believe your father is a sixth or seventh cousin of Hiram’s. You don’t
have to puzzle it out—it’s worse than the ship-time that Hiram is
always trying to get me to learn.”

They went down from the deck presently and Aunt Grace said she
thought Doris should lie down and take a little nap. This gave
Elizabeth Ann an excellent chance to study the mahogany clock, and
listen to it strike. And if ever she had said in her careless little mind
that Aunt Grace was “silly” not to learn ship-time, Elizabeth Ann was
soon sorry.

For the more she puzzled over the eight bells, and the two and
three bells, the more confused she became. And when Uncle Hiram
came in and asked her where the first mate was, Elizabeth Ann
merely raised her head and stared at him.

“Who—who is the first mate?” she stammered uncertainly.

“Your Aunt Grace, to be sure,” said Uncle Hiram. “I’m the Captain
of this ship and she’s first mate. She stands the forenoon watch.”

“Is that the watch you carry in your pocket?” Elizabeth Ann asked,
beginning to feel that she didn’t understand anything Uncle Hiram
said.

“No, the forenoon watch is from eight o’clock till noon,” said Uncle
Hiram. “That’s the morning hours, you see. At eight bells, or 12
noon, I come up to the house for dinner.”

Elizabeth Ann blinked.

“How many bells is it now?” she asked, pointing to the clock which
said half-past eleven.

“Why, it’s seven bells,” Uncle Hiram replied promptly.


Then and there Elizabeth Ann decided that she must be like Aunt
Grace—it was so much easier to say “half past eleven” than to count
up to seven bells. Of course it was easier for Uncle Hiram to tell time
that way than by the regular time, for he had done it so long.

“Don’t bother your head about it,” he said now, noticing that
Elizabeth Ann was bewildered. “Perhaps you’ll pick it up as you go
along, and if you don’t, it doesn’t matter. Your Aunt Grace was
brought up on a farm and she can’t learn about the sea; I went to
sea when I was a young lad and I can’t pick up land ways. But we
each do our way and get along splendidly. There’s more than one
way of doing a thing and I haven’t much use for any man who thinks
his is the only possible one.”

Elizabeth Ann thought that was very nice. If she learned to tell
time by the bells that would be fine—she could surprise Lansing and
Ted. But if she didn’t learn, Uncle Hiram wouldn’t be annoyed—he
thought that the old way of telling time—by the old way, Elizabeth
Ann meant the way she had been taught—was good, too.

Uncle Hiram had come up to the house before noon because he


wanted to drive to Gardner as soon as dinner was over and, he
explained he could get ready to go before dinner.

“I could ship two passengers,” he announced, a twinkle in his eye.

“That means we can go, Doris!” cried Elizabeth Ann joyfully.

“Does it?” Doris, who had just woke up from her nap, and was still
a bit sleepy, inquired doubtfully.

“Of course you may go,” said Aunt Grace, who had found time to
cook a marvelous dinner—with peach shortcake for dessert—
informed them. “Uncle Hiram just loves to have company with him
when he drives to Gardner.”
Aunt Grace wouldn’t hear of them waiting to help her with the
dishes—she said there were not many, and she was used to doing
them alone—and when Elizabeth Ann and Doris went outdoors to
get into the car, they found Tony sitting on the front doorstep,
washing his face as though he had always lived in the “Bonnie
Susie.”

“Isn’t it nice to live in a house like that!” exclaimed Elizabeth Ann


proudly, looking back to wave to Aunt Grace as they drove away.

“Pretty good ship, if I do say it myself,” Uncle Hiram agreed


proudly.

And all the way to town he told Elizabeth Ann and Doris stories of
what had happened to him while he was at sea.

“I can feel the way the hammocks used to sway in a storm, even
now,” he said. “I still sleep in a hammock, but your Aunt Grace
couldn’t get used to one; she had to have a bunk.”

Elizabeth Ann and Doris looked at each other. They were glad they
had bunks instead of hammocks—a hammock was all very well to
sleep in for an hour or two on a warm afternoon, but they didn’t
care to sleep in one.

Gardner was a pretty little town, about four miles from the farm.
There was one main store, where almost everything was sold that
you could mention. Uncle Hiram drove directly to this store and he
said Elizabeth Ann and Doris might come in with him while he
bought the things he had come for—knives for cutting corn, and
gloves for the men who were to cut it.

“Hello,” said Uncle Hiram as soon as he went into the store.


“Elizabeth Ann—Doris—here’s one of your neighbors. Catherine, this
is Elizabeth Ann Loring and Doris Mason, my nieces. They’re going to
school to-morrow, and Aunt Grace was saying she hoped you’d stop
for them as you go past the house. Catherine Gould lives near us,”
Uncle Hiram added.

Elizabeth Ann and Doris saw a pretty girl, about their own age,
very beautifully dressed. She didn’t look as though she could have
much fun in her pink silk frock, but it certainly was pretty. And she
smiled at Elizabeth Ann and Doris and was about to say something
when suddenly she frowned and looked so cross Elizabeth Ann was
startled.

“Hello, Cathy!” said a boy’s voice, and a lad in faded overalls, with
a large package under his arm, pulled off his cap and smiled as he
passed the three girls.

“Hello, Roger!” Uncle Hiram boomed in his deep voice.

“I’m surprised your uncle speaks to him,” said Catherine, looking


crosser than ever. “Roger Calendar is only a taken boy.”
CHAPTER VIII

ROGER CALENDAR

Elizabeth Ann—the famous little question mark, as Uncle Doctor


had once jokingly called her—thought of several things she wanted
to know. She remembered the taken boy the man had been hunting
for when he met Uncle Hiram the day before. She wondered
whether Roger Calendar could be that boy. She wanted to know if
people called him a “varmint.” She wanted to know——

But Uncle Hiram had overheard Catherine’s remark. And if


Elizabeth Ann and Doris had ever wondered whether he could be
really cross, they knew the answer now. Uncle Hiram was not at all
pleased.

“I don’t know what your father would say, Kitty, if he heard you
make a remark like that,” said Uncle Hiram. “Roger Calendar is a fine
boy in every respect. I hope the other pupils in school don’t feel
toward him as you do.”

“Oh, no one pays any attention to him,” Catherine replied. “He


keeps to himself. I guess he doesn’t feel just right among the rest of
us. I don’t think the Bostwicks ought to send him to school, but Mr.
Bostwick told my father he had to; there’s a law that all children
have to be educated.”

“It’s a pity there isn’t a law that says all children have to be taught
kindness and politeness,” said Uncle Hiram. “I hope Elizabeth Ann
and Doris will have too much sense to follow your example.”
Catherine Gould didn’t seem abashed. She merely smiled a little,
as though Uncle Hiram was mistaken about her. Then she told
Elizabeth Ann that she would stop for her and Doris the next
morning “in time to get the bus,” and went out of the store.
Elizabeth Ann saw her cross the street and get into a beautiful dark
blue car—a much larger and handsomer car than Uncle Hiram’s.

“Isn’t she pretty!” said Doris wistfully. “And did you see her dress?
I wanted a new dress, but Mother said I’d better wait till Christmas
time.”

“I don’t like her so much,” Elizabeth Ann declared.

“Catherine is a nice girl,” said Uncle Hiram who had wonderful


hearing and seldom missed a word. “She’s a fine girl, in many ways;
but her father is the wealthiest man in this township, and Catherine
is the only child and I’m afraid she is a little spoiled. No one but a
silly, spoiled girl would talk as she does about Roger Calendar.”

“Is he the taken boy who was lost?” asked Elizabeth Ann quickly.

“Oh, my, no,” Uncle Hiram answered. “That poor boy must live
many miles away from us. I never saw the man before who was
searching for him. Roger Calendar lives with the Bostwicks whose
land adjoins ours on one side. The Goulds live on the other side.
Catherine and Roger must go in to school every morning on the
same bus, when school is in session; I don’t like to think of her
being rude to him.”

As it happened, Elizabeth Ann and Doris had a chance to become


acquainted with Roger Calendar on the way home. Uncle Hiram
came up with him about half a mile out of town, and offered him a
“lift.”

“You children want to know each other,” said Uncle Hiram, as


Roger climbed into the seat beside him. “Elizabeth Ann and Doris,
this is Roger Calendar who is our neighbor; and Roger, these are my
nieces. They start school to-morrow, and if they’re late for the bus
you let me know. I don’t let anyone on my ship get tardy marks
more than once.”

Roger smiled a little shyly at the two girls. He had a friendly face
and nice dark eyes and hair. But his clothes were terribly patched
and Elizabeth Ann didn’t wonder he was ashamed of his shoes. She
caught a glimpse of them, patched with great squares of different
colored leather, before Roger seemed to suddenly remember them,
and then he thrust his feet out of sight, under the seat as far as they
would go.

“You’ll be on time all right, if Cathy Gould calls for you,” said
Roger. “Hardly anyone is late, anyway, because if you miss the bus
you never can walk to school in time for the nine o’clock bell. The
only thing to do is to turn around and go home and be marked
absent for a day.”

When they reached the road that led to the Bostwick farm, Roger
insisted he must get out.

“I’ll drive you all the way in,” offered Uncle Hiram. “I have plenty
of time. That package you are carrying is too heavy for a boy your
size, anyway. Better let me take you right up to the barn door,
Roger.”

“No, please,” Roger said, getting out of the car so hastily that he
almost tripped. “You’re awfully good, Mr. Kent, but Mr. Bostwick
doesn’t like me to take rides. He wouldn’t like it if he saw you
bringing me home.”

“What did I tell you about calling me Mr. Kent?” said Uncle Hiram
in his crossest voice.

“I forgot—I honestly did,” Roger apologized. “I meant to say ‘Uncle


Hiram.’ Good-by, Uncle Hiram, and thank you a lot for the lift. Good-
by, Elizabeth Ann and Doris—see you in school to-morrow.”
He lifted the heavy package that pulled him over sideways when
he carried it, and almost ran down the road to the Bostwick farm.

“Does everyone call you Uncle Hiram?” asked Elizabeth Ann


curiously.

“Just about everybody,” Uncle Hiram assured her, smiling. “Your


Aunt Grace and I long ago made up our minds that we’d have
nephews and nieces by the dozen and we seem to have them.”

Tony was still on the front stoop of the Bonnie Susie when they
reached home. But he consented to follow Elizabeth Ann and Doris
out to the corn field. They wanted to see the corn being cut and
Uncle Hiram said it was high time they saw the farm.

The tenant farmer, whose name was Mr. Lawton, and his two sons
were cutting corn, and Elizabeth Ann and Doris watched them for a
while as they went up and down the long rows. Tony caught a field
mouse and was so pleased with himself that Elizabeth Ann scolded
him, and told him he was vain.

“You run up to the house, and see my wife,” said Mr. Lawton, the
first time he stopped long enough to talk to them, “and she’ll show
you what she has been doing this morning and, likely as not she’ll
give you a sample. Mother likes to give away samples.”

Uncle Hiram wanted to stay in the field and as Elizabeth Ann and
Doris could see the farmhouse from where they stood, there was no
reason why they couldn’t go alone to call on Mrs. Lawton. Elizabeth
Ann thought she would be surprised to see them, but when they
rang the old-fashioned pull bell and a stout, pink-cheeked woman
came to the door, she didn’t look at all surprised to see two little
girls on her door step.

“You’re the two little nieces Mrs. Kent has been expecting, aren’t
you?” she said pleasantly. “I’m Mrs. Lawton, of course. Come right
in. If you don’t mind coming into the kitchen, I can finish putting the
labels on my jelly.”

Mrs. Lawton’s kitchen was most pleasant, though not, Elizabeth


Ann decided, quite as nice as Aunt Grace’s kitchen which Uncle
Hiram would call the galley. But the Lawton kitchen was large, and
there was a great fire in the range and oh, my, how deliciously the
room did smell.

“I’ve made forty glasses of grape jelly this morning,” said Mrs.
Lawton proudly. “I’d like you to try some on bread and butter; I
always think jelly tastes better on bread and butter than any other
way you can eat it. And I’ll be writing my labels while you eat.”

She cut two perfectly huge slices from a loaf of fine white home-
made bread, and spread each of them thickly with butter. Then she
covered the butter with sparkling grape jelly, and put the bread on
two blue and white plates.

“See if you don’t like that,” she said.

Elizabeth Ann and Doris thought the jelly was the best they had
ever tasted. And while Mrs. Lawton wrote “Grape Jelly” on a lot of
little red and white labels and pasted them on the glasses she had
filled, Elizabeth Ann told her about the jam and jelly she had seen in
the cellar of the restaurant; also how the strange woman had
mistaken her for Esther, and had punished her with the ruler.

“Well, I think that was a shame,” said Mrs. Lawton, “and I’ll give
you a glass of jelly for yourself, to help you forget that experience.
And here’s a glass for Doris, too.”

When Elizabeth Ann and Doris showed Aunt Grace the jelly, she
said they should have it in their sandwiches for school the next day.
That made both little girls feel as though school time was very near;
and when they went to bed early that night in order to be ready for
their walk in the morning, they said they knew they would stay
awake and think about the new school. They didn’t, of course, but
went straight to sleep like sensible children, and were very much
surprised to be awakened by Aunt Grace the next morning, and told
that it was time to get dressed to go to school.
CHAPTER IX

OFF FOR SCHOOL

Elizabeth Ann and Doris had just finished their breakfast when
Catherine Gould called for them. Catherine wore the prettiest dress
—perhaps a little too “fussy” for school, but a beautiful green color.
She had a fancy lunch box, too, with all sorts of compartments, for
her sandwiches and a bottle to keep her soup hot in.

Aunt Grace had packed a nice lunch for Elizabeth Ann and one just
like it for Doris; she had told them that their dresses were pretty, too
—Elizabeth Ann wore a blue and white gingham dress and Doris had
a pink one.

“I wanted Daddy to take me as far as the cross-roads in his car


every morning,” said Catherine, “but just because he walked to
school when he was a little boy, he thinks I need exercise. I hate
walking.”

“I like it,” Elizabeth Ann declared, kissing Aunt Grace good-by.

“Do you like living in that funny place?” asked Catherine, as the
three little girls walked down the lane which led to the road they
were to take.

“Why, it’s the nicest house I ever lived in!” Elizabeth Ann said
enthusiastically. “Doris is crazy about it—aren’t you, Doris? We go up
and down ladders instead of stairs, and we sleep in bunks instead of
beds. And the roof is a deck, and it’s the nicest place to play you
ever saw.”
“Yes it is,” declared Doris, forgetting her shyness. “And Elizabeth
Ann can tell ship-time—she learns everything.”

“Oh, Doris, I only know a little bit about it,” Elizabeth Ann
protested, turning red. “I have to stop and count, and most of the
time I get it all wrong.”

Catherine did not seem to be listening. She was peering down the
road.

“Here comes that awful Roger Calendar,” she said crossly. “It will
be just like him to try to walk with us; don’t pay any attention to him
and maybe he’ll let us alone.”

Now Doris might have done as Catherine asked—Doris was apt to


do whatever anyone asked of her. But Elizabeth Ann liked to do her
own thinking, and she remembered what Uncle Hiram had said
about Roger.

“I think he is a nice boy,” said Elizabeth Ann, “and I mean to speak


to him. He lives on the farm next to us; Uncle Hiram said so.”

“He only lives with the Bostwicks who own the farm,” said
Catherine scornfully. “Roger is a taken boy—didn’t you hear me tell
you that yesterday? He used to live at the poor farm, until the
Bostwicks took him. He works for them, and the only reason they
send him to school is because the Board of Education makes them.”

Roger was waiting at the Bostwick mailbox as they came up to


him. He did not seem to notice that Catherine looked straight and
pretended not to see him.

“Hello, Catherine,” said Roger. “Good morning, Elizabeth Ann. How


are you, Doris? Are you glad or sorry school has started?”

Roger fell into step beside Elizabeth Ann. He carried a small brown
paper parcel in his hand—his lunch, probably, thought Elizabeth Ann,
who also suspected that there could not be more than a couple of
sandwiches in such a small package. Two sandwiches were not
much lunch for a hungry boy, she thought. Aunt Grace had insisted
on making four apiece for her and Doris.

“I like school,” said Elizabeth Ann, as Doris didn’t answer and


Catherine continued to stare straight ahead. “I’m not sure about this
school, but maybe I’ll like it.”

“If you’re in our class, you’ll like school,” declared Roger. “We have
the finest teacher in the whole school, haven’t we, Cathy?”

Catherine whirled upon him.

“Roger Calendar, if you don’t stop calling me ‘Cathy,’ I’ll do


something awful to you!” she scolded. “I’ve told you twenty times I
hate it.”

“I’m sorry,” apologized Roger. “I keep forgetting. Isn’t Miss Owen a


nice teacher, Catherine?”

Catherine tossed her head.

“You may like her,” she said coldly. “I never could see anything in
her to rave about. Sometimes she gets too cross for words.”

“She’s a fine teacher,” declared Roger. “You’ll like her, Elizabeth


Ann.”

“Here comes Mattie Harrison,” Catherine announced, waving her


hand to a little girl who came running across a plowed field.

Mattie Harrison was quite breathless when she reached them. She
was short and fat and her brown eyes twinkled as Catherine
introduced her. Elizabeth Ann liked her at once because she spoke to
Roger and asked him if he had had a nice summer.
“I guess he worked the same as usual,” said Catherine in what she
may have intended to be a low voice, but which Roger heard, for his
face flushed.

He said nothing, however, and went on talking to Elizabeth Ann


and Doris, while Catherine and Mattie walked ahead.

Elizabeth Ann knew when they were coming to the cross-roads


because she saw a group of children waiting there. She counted a
dozen boys and girls, and all of them knew Catherine and Mattie and
Roger, for they called them by name. Doris was quite overwhelmed
at the sight of so many strangers, and she tried to hide behind
Elizabeth Ann, but Mattie proved to be an expert at helping people
to know each other and before the bus came she had introduced
Doris to a little girl almost as shy as herself, and the two were
talking like old friends. This other little girl’s name was Coralie—
Coralie Slade, and Doris liked her.

“Honk! Honk! Honk!” sounded a deep hoarse horn presently.

Down the road came a great gray, lumbering bus. It stopped


within three feet of the waiting children and the grinning young
driver looked out at them.

“Line up,” he commanded. “Who’s the little girl in the blue and
white dress? Did she ride with me last winter?”

“She’s Elizabeth Ann Loring, Dave,” said Roger Calendar. “And this
is her cousin, Doris Mason. They’re going to spend the winter with
Uncle Hiram and go to our school.”

“Let company get in first,” Dave, the driver, directed. “Hop in,
Elizabeth Ann Loring, and Doris Mason.”

Dave evidently had his passengers well trained. None of the


children moved after they had formed themselves into a straight
line. They waited to see what Dave wanted them to do.
Elizabeth Ann and Doris stepped into the bus. It had long seats
down either side and these were about half filled with boys and girls.
Some were older—they afterward learned that these were pupils in
the higher grades.

“Glad to know you,” said Dave from behind his wheel. “Sit down
anywhere you like. Now then, line move up—one at a time and
anyone who crowds goes to the foot of the class.”

One by one the boys and girls filed into the bus and took seats.
Elizabeth Ann, watching, saw at once how wise Dave was to make
them enter one at a time. If they had tried to board the bus in a
struggling crowd, it would mean only confusion and delay. Dave kept
an eagle eye on the entering line and no one dared push his
neighbor. Elizabeth Ann saw that the girls came first—Dave had
taught the boys to wait their turn.

“All right,” said Dave, when the last pupil was safely in. “I hope
you’ll all study your books and improve your time on the way to
school.”

This was a joke and everyone laughed at it. Of course there were
no lessons to be studied the first day of school. Instead the boys and
girls talked to each other, and as the bus made a great noise the
children had to shout to make themselves heard. Dave did not seem
to mind the noise—— Roger told Elizabeth Ann that he was used to
it, since he had driven the school bus for three years. But while Dave
didn’t mind noise, he wouldn’t allow anyone to leave his seat and
play in the aisle. It was the rule—Roger told Elizabeth Ann this, too
—that if anyone left his seat Dave would stop the bus at once, and
refuse to go ahead until the boy or girl sat down again.

“We haven’t any too much time and if Dave stops even once or
twice, we may be late,” Roger shouted to Elizabeth Ann. “Once the
whole bus load was late, and we had to stay an hour after school.
That made us miss the bus home and we all had to walk. Dave
won’t stand for any skylarking, and the kids know he means what he
says.”

The bus made two more stops, picking up four boys and two girls
at one place, and three girls and three boys at another. Then it was
comfortably filled and Dave drove steadily and at a fair rate of speed
until they came in sight of a large brick building with a fenced in
yard in front of it, and a flag on the flag pole near the gate.

“There’s our school,” said Roger as the bus stopped.


CHAPTER X

A BUSY MORNING

Elizabeth Ann peered through the window—she and Doris were in


the back of the bus and couldn’t hope to get out for several seconds.
Elizabeth Ann saw that the yard fairly swarmed with children, and
that they made a rush for the gate to see who had arrived on the
bus.

“I think this school is too big,” whispered Doris, who felt she had
seen enough strange children to last her for a long time.

“Oh, we can play tag and everything,” Elizabeth Ann reminded her
happily, standing up because the girl in front of her was standing up
and that meant it was time to leave the bus.

Elizabeth Ann had no brothers or sisters, and she had never in all
her life had too many children to play with. She thought that school
yard was a fine place and she could just see herself playing tag in it
from one end to the other.

“You have to go in and be registered,” said Catherine Gould.

These were almost the only words she had said since Roger had
begun to talk to Elizabeth Ann. Catherine had talked to Mattie
Harrison most of the time.

“Where do we register?” Elizabeth Ann asked, following Catherine


out of the bus.
Doris came next and pressed close to her cousin. Doris was
beginning to wish she had not come.

“I’ll show you,” offered Catherine, pushing her way through the
groups of laughing, chattering children.

Elizabeth Ann and Doris followed her into the building, down a
long hall, and up a short flight of stairs.

“Miss Owen, here’s Elizabeth Ann and Doris,” said Catherine, as


soon as she opened the door nearest to the stairs.

Miss Owen, the teacher, was talking to another teacher at her


desk. She looked surprised, but when she saw Elizabeth Ann and
Doris she came over to them instantly.

“How do you do?” she said in a lovely voice. “I’m glad you are
going to be in my room this term. Your Uncle Hiram wrote to me
about you and I’ve been expecting you.”

Of course that made even the shy Doris feel at home at once.
Then Miss Owen showed them their desks and the cloakroom and
then the nine o’clock bell rang and it was time to go down stairs
where the auditorium was, and where assembly was held every
morning.

This was the largest school Doris had ever attended. It was the
largest Elizabeth Ann had ever gone to, except the school where she
had been a pupil in New York when she visited her Aunt Isabel. This
new school was, as Aunt Grace had explained, really six or seven
little country schools rolled into one—and when all the pupils were
gathered together in the auditorium, they filled all the seats that
were arranged in rows on the first floor, and rose in tiers in the
gallery.

And how they could sing! One of the older pupils played the piano
for them and when the students sang the hymn Elizabeth Ann
wondered whether Uncle Hiram, at home in the Bonnie Susie,
couldn’t hear them. She sang, too, and so did Doris. It was
impossible to be in that auditorium and not join in the song.
Elizabeth Ann knew right away that she was going to like the new
school.

Afterward she was just as sure. They marched back to their class
room and Miss Owen began to teach them spelling. They had
spelling and reading, and then it was time for recess. They were
allowed twenty minutes for recess, and Miss Owen made every one
of them go out and play in the yard. She said no pupil of hers could
sit indoors on such a fine day.

Elizabeth Ann and Doris were asked to join a game of jack stones
with Mattie Harrison and another little girl who had not been on the
bus. Her name was Flora Gabrie. Catherine Gould walked up and
down the yard with her arm around one of the older girls and
seemed to be listening intently to what she was saying.

“That’s Lenora Miller,” said Mattie, pointing to the older girl.


“Catherine Gould thinks everything Lenora says is just right. I
shouldn’t wonder if Lenora gets herself invited to Catherine’s party.”

“Is she going to give a party?” asked Elizabeth Ann, who could ask
questions and scoop up jack stones at the same time.

“Catherine is always giving parties,” Mattie informed her. “She lives


in a great big house, and her mother lets her do anything she
pleases.”

The bell rang for the end of recess just then, and the rest of the
morning Elizabeth Ann was too busy trying to learn to write nicely, to
think much about parties, or girls whose mothers allowed them to
do anything they pleased.

Mattie had explained to Elizabeth Ann and Doris about the lunch
hour. In the winter she said, there was a large, warm, light room in
the basement with tables, where the pupils ate their lunches. But as
long as the weather remained warm and pleasant—as it usually did
throughout September—the children were supposed to eat their
lunches outdoors.

“Miss Owen,” Mattie had explained, “is crazy about fresh air.”

At noon, when the bell rang, Elizabeth Ann was starving. She was
sure she had never been so hungry before in her life.

“Come on, we have to hurry, or we don’t get a tree,” said Mattie,


who certainly knew all about school.

Elizabeth Ann grasped her lunch box and caught hold of Doris’s
hand.

“Hurry!” she said, and helter skelter across the play ground they
ran, to a row of apple trees that were behind the building.

Boys and girls were climbing into these trees—you know an apple
tree is close to the ground and easy to climb—and though Elizabeth
Ann and Mattie both had to tug and pull Doris, to get her up into the
tree, they all agreed, once they were settled, that it was a lovely
place to eat lunch.

They could look out through the branches, and the way the limbs
of the tree grew sitting in it was as easy as sitting in a comfortable
rocking chair.

“Hello!” called Roger Calendar, leaning out from the tree next to
the one where Elizabeth Ann and Doris and Mattie were perched.

“Hello!” Mattie answered. “Did you see your writing that Miss
Owen pinned up on the board?”

Roger blushed and ducked behind a convenient branch.


“Are you on a diet, Roger?” Catherine Gould called to him. “Are
you afraid you’re getting too fat?”

Catherine sat on the grass, eating her lunch with several of the
grammar grade pupils. Catherine never would climb a tree, Mattie
whispered to Elizabeth Ann. She said that only boys liked to climb
trees.

“Why, I like to climb ’em,” said Elizabeth Ann, meaning the trees.
“So does Doris, though she can’t climb a very high tree. Lots of girls
like to climb trees.”

“Of course they do,” Mattie agreed. “Catherine only says that,
because she doesn’t like to climb trees. And she’s mad because
Roger’s writing was the best in the class this morning, and Miss
Owen pinned it on the board. When Catherine is mad you can
always tell—she says some mean thing.”

“Why—what did she say that was mean?” asked Elizabeth Ann,
not understanding.

“Oh, that about asking Roger if he was dieting to keep from


getting too fat,” Mattie explained. “Poor Roger gets only two
sandwiches for his lunch. He’s almost always hungry. The Bostwicks
don’t think he needs much to eat—my mother says they don’t eat
much themselves, and they forget when a boy is growing he needs
plenty to eat. Roger can eat his lunch in two minutes and it’s mean
of Catherine to ask him if he’s afraid of getting fat. He’s the thinnest
boy in school now.”

Yes, Elizabeth Ann could see that kind of thing was unkind for
Catherine to say. You couldn’t excuse her, either, by telling yourself
that she didn’t know about Roger. Catherine lived near Roger and
knew all about him—that he was a “taken boy” and dependent upon
the people for whom he worked for his food and clothing. There was
every reason in the world why Catherine Gould, with a father and
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookluna.com

You might also like