100% found this document useful (2 votes)
8 views43 pages

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

The document provides information about various eBooks available for download, including titles related to Python programming, nursing practice, and creative writing. It highlights the content structure of 'The Practice of Computing Using Python, 3rd Edition,' which covers topics such as data manipulation, programming basics, and algorithms. Links to download the full versions of these eBooks are included.

Uploaded by

qygpohbwk8949
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 (2 votes)
8 views43 pages

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

The document provides information about various eBooks available for download, including titles related to Python programming, nursing practice, and creative writing. It highlights the content structure of 'The Practice of Computing Using Python, 3rd Edition,' which covers topics such as data manipulation, programming basics, and algorithms. Links to download the full versions of these eBooks are included.

Uploaded by

qygpohbwk8949
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/ 43

(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
Another Random Scribd Document
with Unrelated Content
The Liverpool Drydock
The Gladstone Dock in Liverpool was the only drydock in the world at the
time that would take the Leviathan. The entire development of this dock,
which included a tidal basin, was not completed when the war broke out, so
the tidal basin was abandoned and one of a pair of docks was finished up and
a long channel dredged to the River Mersey.
The ship drew so much that we could not enter the dock except at the
spring tides, or in other words, only about two days out of a month would
permit us to enter the dock, provided the wind did not cut the tide too much.
The next thing was to decide on how to prepare the beds of the drydock to
receive the ship. An examination of her bottom was necessary. Divers were
sent down and they reported that she had neither docking nor bilge keels,
and that her keel plate consisted of a plate of about 2 inches thick by 3 feet
wide.
In converting the ship from a passenger to a troop ship, we naturally
became familiar with every detail of her construction. With this knowledge of
her construction and due consideration being given to the location of the
heavy weights, etc., it was decided to place the main bed under the third
intercostal, this bed running from frames 220 to 101, or a distance of 358 feet
amidships. The spacing of these blocks was 6 feet, or every other frame
space. The center of these blocks was 25½ feet from the center line of the
ship.
In addition to the center line bed, which is placed underneath the keel, and
the two main beds, one port and one starboard, which is placed under the
third intercostal, an outer bed, consisting of four sets of five blocks each,
space 6 feet centers, was placed under the fore and aft coal bunker bulkhead,
at the intersection of the thwartship bulkheads.
The fore and aft center of these blocks came at frame 199, 174, 151 and
126. Blocks of the outer bed were staggered with those of the inner bed. This
outer bed was 35 feet from the center of the ship. At the fore and aft ends of
the ship where the dead-rise is considerable, an inner bed a few inches from
the center of the ship for a distance of 60 feet was prepared, 12 feet 6 inches
forward, and 13 feet 9 inches aft.
After deciding the location of these beds, the next step was to get some
idea of how to prepare them, so that they would conform to the shape of the
ship. Preparing the center line bed was of course easier, as it was known that
the keel of the ship was a straight line.
The forward end of the center line bed consisted of a solid line of blocks for
a distance of 104 feet, and the after end of a solid line of blocks for 144 feet,
where exceptionally heavy weights would be carried. The balance of the
blocks was spaced every 15 inch centers, except in the way of water-tight
bulkheads. Under these bulkheads the blocks were filled in solid for 7 blocks.
On each side of these, two spaces were omitted and then filled in solid for 5
blocks. Reference to the docking plans will show the spacing of these blocks.

Blocks and Beds


An idea of the blocks used in building the beds can be had by referring to
the photograph. They consisted of 3 cast steel wedges, which, when placed
upon each other, were about 3 feet high, 15 inches wide at the bottom, and 3
feet 6 inches long. On top of these steel wedges was placed a hardwood block
12 inches square and 4 feet long, and on top of the hardwood blocks was
placed a soft wood cap 12 inches wide by 4 inches thick by 4 feet long.
To prepare the main, inner and outer beds, it was necessary to have some
idea of the form of the ship. By opening up the water-tight doors in the
fireroom we were able to get a base line 300 feet long. Every other double
bottom tank was pumped out and offsets taken at the fore and aft ends of
these tanks, in way of the main, inner and outer beds. The taking of these
offsets was greatly facilitated by the fact that the double bottom was found to
be flat in both the fore and aft thwartships direction. Buttocks were run
through these offsets. While these buttocks faired up very well, it was realized
that the measurements would not be accurate enough for the actual
preparation of the beds; therefore they were prepared to within 4 inches of
these measurements.
Several hundred wedges of varying thicknesses were made ready in
advance, and after the ship was placed on the center line blocks, the space
between the main and outer beds and the ship’s bottom was packed with the
wedges by divers.
The Gladstone Dock was prepared according to the above description,
carefully checked and measured, and then flooded to about 10 feet, so that
no one could tamper with it. After the dock was prepared, we had to wait
several days for a spring tide, and also to dredge out a shifting shoal at the
entrance of the channel leading to the dock.
The first tide that the ship could enter the dock was at 11:50 A. M., January
14, 1918. She was brought to as even a keel as possible, which was 35 feet 9
inches forward and 37 feet 6 inches aft. This was accomplished by filling the
forward tanks and emptying the after tanks and placing about 1,400 tons of
coal in her reserve and forward bunkers. This was the nearest to an even keel
that we had ever had the ship up to this time in the light condition. I might
mention here that in this condition the ship is extremely tender, and that
Lieut. Watts of the Engineering Department, displayed great diligence and
good judgment in keeping her perfectly upright, while setting her on the
blocks.

Entering the Dock


On January 14, 1918, the ship proceeded down the Mersey River to the
entrance of the dock, but the wind was too high to attempt making the
entrance, and we had to return to Princess Landing. On the 15th conditions
were much better but none too favorable. However, as it was the last day of
the spring tide we had to make the attempt. The spring tides are about 21
feet, and the current is very swift, so we had less than an hour in which to
enter the dock and close the caisson.
The entrance was very narrow, so that tugs were of little assistance and she
had to go in under her own power. It was a fine piece of seamanship and was
successfully accomplished without damage to either the ship or the dock. The
handling of the ship in the long entrance channel to the dock was done by the
Senior Captain of the Cunard Line on shore. We were all greatly shocked
about two weeks later to learn of his death, due to a channel steamer being
torpedoed on its return from France, where he had been called on an
important conference. It was the loss of such fine men through the
treacherous German submarines that brought home to us more than ever our
solemn duty to beat the Germans at all costs.
On the 16th everything was ready for setting her on the center line blocks.
The weather conditions were ideal; the wind was on the stern and the ship
was on an even keel. The stern touched the blocks and she settled at 3:55
P. M.
Previous to setting the ship on the blocks 12 sighting battons were erected
along the level of “B” deck from stem to stem, so that if the ship was strained
in any way it could be readily noted. A piano wire was also stretched from
side to side at the top of the thwartships coal bunkers amidships and
connected to a spring balance, so that any opening up effect, due to the
divers not properly packing the main beds, would immediately show.
As soon as the stern touched the blocks the top row of side shores were set
up commencing from aft. These shores were spaced every 5 frames, or about
15 feet centers. Altogether there were three rows of these side shores. The
water was then lowered to a depth of 32 feet and the water maintained at
this depth while the divers packed the main, inner and outer beds. As soon as
possible after the water reached 32 feet, the water in all the tanks was
pumped out with the exception of the feed tanks and No. 23 and 24 fresh
water service tanks. The stem and side anchors were lowered and the pig iron
in No. 17 tank, amounting to about 473 tons, was removed.
The water was maintained in the dock at 32 feet, because at this depth the
ship was just resting nicely on the center line blocks and would not compress
the soft wood caps. We did not want any unnecessary weight on the center
line blocks until the divers had finished their work on the main and outer
beds, so that when the dock was finally pumped out, the ship would imbed
itself in the soft wood capping at a uniform depth. This worked out
exceptionally well, and was remarkably uniform on all beds, amounting to
about 2 inches at the end of the third day. On the third day the spring balance
on the piano wire registered less than an ounce difference. The sighting
battons showed that she had settled amidships about 1⅜ inches. After
floating she returned to ⅛ inch of the original condition. This I believe to be
the natural hog of the ship.
The undocking of the ship was somewhat unusual in that 7,800 tons of coal
were placed aboard while she was in dry dock, 1,400 tons while the dock was
absolutely dry and the balance of the coal, with from 35 to 37 feet of water in
the dock. This was not sufficient to float the ship, and she still rested upon
the docking beds. Immediately before letting in the water, all the bilge and
hanging shores, and shores under, the stem and stern that would in any way
injure the ship should she take a sudden list, or any undue change of trim,
were removed. These shores were removed at about 15 minute intervals, so
that the ship could adjust itself and any undue settling could be noticed.
During this operation men were stationed at the sighting battons and the
piano wire. Water was then admitted as quickly as possible to 35 feet and
maintained at this level while additional coal was put aboard from barges
admitted to the dock at low tide. This was a rather trying ordeal, but was
successfully accomplished in 5 days.
Arrangements had been made to leave the dock on February 11th. It was
therefore decided to float her on the 10th, and an estimate was made of the
coal on board and such tanks as were necessary to bring her to an even trim
and even keel, were filled. She floated at 1:20 on the 10th with 38 feet 11
inches draft aft, 39 feet 6 inches draft forward, and less than ½° list to
starboard.
I cannot speak too highly of the hearty co-operation received from the
ship’s officers and crew, especially Naval Constructor J. H. Jack, U. S. N. This
applies not only to the docking of the ship, but to her conversion from a
passenger ship to a transport. No duty was too strenuous or hours too long,
and during the conversion the living quarters on the ship were not of the best.
They were continually shifted from one part of the ship to the other, even the
meals were of a makeshift character and at times irregular. Every man
seemed to realize what we were up against and that we must make good.
Everyone pulling together, accomplishment was made possible.
The conversion of the ship to a transport speaks volumes for the Navy
Department organization and more particularly for the New York Navy Yard,
under whose direct supervision the work was undertaken.
The ship was so big that she could not be taken to a shipyard, nor
transferred to the Navy Yard. The task had to be undertaken where she lay at
her piers in Hoboken and the New York Navy Yard organization was elastic
enough and active enough to carry on the work outside the Navy Yard.

The Bridge

W. J.
General conditions on the bridge were good. Instruments had deteriorated
somewhat, owing to the long stay in port and not being used.
All signal flags and navigation instruments, including the three
chronometers which comprised part of her equipment were removed. The
ship was equipped with two master gyroscopic compasses installed on “G”
deck and seven repeaters for use on the bridge in steering and taking
bearings; these were all found to be more or less in need of repairs and after
days of hard and tedious work on the part of Lieut. W. H. F. Schluter and his
well organized staff they were put in fine condition and have been kept in this
manner constantly even though he has had to add pieces of lead to each
master gyro to maintain a level. Being of German manufacture, no spare parts
could be obtained during the war, but whenever they were needed Lieutenant
Schluter proved to be the “man of the hour.” The gyros were only one of his
many troubles for, being electrical officer, there were numerous other duties
about the ship. There were a great many German charts left on board but the
ship was equipped by the Bureau of Navigation with American charts before
leaving port. The steering gears and all the telegraphs were changed to
English speaking. The deep-sea sounding machines are still in commission
after a great amount of usage, and the motors attached to them for heaving
in the lead are still in good working order. The patent log for measuring
distance is the “Forbes,” an English patent. Loudspeaking telephones reached
to all the principal parts of the ship, and are very much used. A fire-alarm
indicator is placed in the wheelhouse and is set at fifteen-minute intervals.
This indicator has pipes leading to all holds through which the smoke from
any fire in a hold would be drawn and can be seen in the wheelhouse when
the alarm goes off. A steam hose can be connected to the pipe and the fire
smothered. There is a control for operating water-tight doors and a diagram
showing location of each door; upon this diagram an electric light burns when
each door is closed, showing the officer of the deck whether the control works
properly.
The big 44-inch searchlight on the foremast is controlled very readily from
the bridge by a small lever; the fog bell is rung and all whistles are blown by
an electrical attachment. The master electric clock is on the bridge and gives
the time to 550 repeaters situated throughout the ship. These clocks required
a great amount of painstaking labor to be put into good condition and
demand constant care and supervision. During the alterations in which first
class staterooms were ripped out to make troop quarters, the wiring system
to the clocks was torn out by the workmen as well as everything else which
happened to be in their path.
As mentioned previously the ship’s chronometers, three in number, were
missing. These were afterwards found by the Secret Service in a nautical
school in New York City. The commanding officer had to send them to the
Naval Observatory at Washington, D. C. This was done with great reluctance
as they were of the finest type and a good chronometer is a very valuable and
much used article aboard a ship. Others were sent to replace them. The
bridge and signal bridge were altered for transport purposes. The fire control
and range finder stations being built on the signal bridge, and the fine bright
finish of the wood was changed to the more popular color at that time—the
war gray. Otherwise the Leviathan remains the Vaterland, as when she was in
the merchant service—a German transport in disguise.

The Deck Force


F. C. W.
When the Leviathan was taken over by the Navy, the chief difficulty that
presented itself was the scarcity of men available for the deck force. Only a
few of the crew that had been assigned to the ship had ever been to sea. A
few—gun crews, for the most part—had had some experience, but not
enough to qualify them as seamen. This was partly due to their short terms of
service.
As a result, the brunt of the work fell upon the shoulders of a few
experienced petty officers, who fortunately had been assigned to the ship.
These men worked day and night in a supreme effort to organize their crews
and create a working machine. For the first few days they did everything from
scrubbing the decks to exploring the double bottoms. There was no distinction
between the rated men and the seamen in this line of work.
The size of the ship added to the confusion. It was impossible to keep a
detail together for more than a minute and a half. It was easy for an entire
working party to get lost between decks. It was easier for some to get lost
than others. Finally, it was decided that the only way to keep a working party
together was to hang a bell around the neck of the petty officer in charge.
This scheme worked well until two working parties met, when it was
necessary to call in a traffic cop to get them separated.
Because of their unfamiliarity with the ship, details were apt to deliver sacks
of “spuds” to the Commander’s cabin, and stationery to the blacksmith shop.
This situation was relieved by the appointment of guides to conduct the
working parties around.
The parts of the ship allotted to the deck division (at that time we could
only boast of one), were in rather good shape, considering the time the ship
had been laid up. The weather decks were littered up like an old woman’s
backyard after a hard day’s washing, but most of the truck was movable.
Boats were piled across the hatches and all over the decks, making it
impossible to get around. Boxes, stores and cordage were everywhere.
The process of making the ship habitable was accomplished by a mere
handful of men, most of the division being assigned to various details for work
in other compartments.
After the work of cleaning up had been completed, attention was turned to
the rigging. The running rigging was in bad shape and it was found necessary
to refit all of the davits that were rigged with manila rope. The booms were
also refitted with new whips and guys. Requisitions for wire and manila lines
were made right and left and all of the rigging was overhauled.
Of the 72 boats on board, 26 were equipped with friction winches and
needed no power for rigging out and loading. The power for hoisting was
furnished by electric motors, each one operating two or more winches. These
winches were given a thorough overhauling and found to be in excellent
condition. The boat falls, which were of special laid wire, were then unrove
and tested. Only two of the entire number needed attention. At that time we
had no serviceable wire, and it was a case of a few well-made long splices.
The ground tackle on the ship was all that could be desired. Of the three
Hall type anchors, the largest, or stem anchor, weighed a little more than
twelve tons. The other two, port and starboard, tipped the scales at eleven
tons. These little trinkets were the only articles on board considered safe from
souvenir hunters. For the information of landsmen, the “anchor watch” has no
connection with the anchor itself, but is merely the men on watch as Officer of
the Deck’s night messengers while the ship is at anchor.
The stem anchor was fitted with a 4-inch stud link chain, 150 fathoms in
length. The port and starboard anchors had chains of 164 and 150 fathoms,
respectively. The chains for the latter were three and three-eighths inches in
diameter, the size of a chain being measured by the diameter of the material
of which the links are formed.
The anchor engines were of corresponding size, and could be connected
with the capstans on deck. In addition to them, there were seven more
engines for capstans in all parts of the ship. In consequence, mooring the ship
to a dock was not the hard task that it usually is.
The stern anchor and chain had apparently been left in Hamburg. The
hawse pipe aft, and the stern chain locker were utilized for the handling and
stowage of the heavy manila hawsers.
Most of the manila hawsers on board had to be replaced. Natural decay or
possibly a small application of acid had so weakened the lines that they had a
tendency to break at the most inopportune moments. The wire hawsers,
however, were in A-1 condition, and up until the present time, have never
been replaced.
But the work of fitting out was not all that had to be done. Men must be
fed; and it seemed, from the accumulation of provisions on the dock, that we
were being depended upon for the entire job of feeding the A. E. F. Truckload
after truckload of stores was piled on the dock, and hoisted aboard, day after
day. We soon learned that one trip with 10,000 red blooded men aboard
involved the consumption of almost everything we had been piling into the
ship’s storerooms and refrigerators. Besides food, there were general stores to
be handled, including everything from safety pins to dishwashing machines.
Every department was working overtime to get things ship-shape, and the
deck force most of all.
At last it was rumored that we were about to make our maiden trip under
the American flag. This was followed by a speeding up in all departments. It
received final substantiation when military equipment and stores began to
arrive. The time had come for a real test.
We had a chance to test our booms when a five-ton truck showed up as a
part of the equipment to be loaded. The booms were of three-ton capacity
and it was necessary to strengthen the lifts and rig a purchase in lieu of the
single whip. It was taken aboard without mishap.
Just before leaving all boat-falls were given a final test. Every boat was
rigged out and lowered to within a few feet of the water. A party of sixty-five
men then clambered in and the boat was hoisted and lowered ten feet or
more. This party was used for all of the boats, which were found to be in
satisfactory condition. A few boats not on davits were hoisted overboard and
tested for watertightness.
One morning in the fall of 1917 we slipped away. There were many
conjectures as to our destination, one opinion being that we were bound for
Panama for a last overhauling in dry dock. It developed that we were taking
1,500 marines to Guantanamo.
Upon our arrival in Cuba, we discharged all equipment and turned our
attention to the boats once more. The boat officers were given their first
lesson in the handling of the boat winches, and some of the men were given
their first experience in a boat under oars.
Back again to Hoboken—more handling of stores and provisions. The
Marines, although few in number, had managed to put quite a hole in our
store of provisions. But the worst was yet to come. Orders sending the ship to
France came, and with them 7,500 soldiers.
We had one piece of luck in getting off. While the crews of other transports
had been compelled to sit and watch civilian stevedores put their stores
aboard, the crew of the Leviathan were allowed to handle everything going
aboard the ship themselves. There were no restrictions whatever, permission
even being given to work night and day at the job. All of the equipment
handled by the civilian stevedores belonging to the army. The crew handled
all of the naval equipment aboard, including Liberty motors, aeroplanes and S.
P. boats.
Liverpool had the honor of receiving us on our first and second voyages.
Here we went into dry dock for final repairs, and here we had our first
experience coaling ship in drydock. Coaling was carried on from cars running
along the dock and also from small lighters or flats in the dock itself. The
lighters were emptied and taken away only at certain stages of the tide. There
was always a chance of the ship floating during one of these manœuvers, and
the work of bringing loaded lighters into the dock and sending the emptied
ones out required quick action and plenty of it. The notorious punctuality of
time and tide is especially noticeable in the Liverpool drydock, and we worked
at all hours of the day and night to keep in step.
The bottom of the ship was given a new coat of paint, and we left for
Hoboken and more troops. On our second voyage to Liverpool our paravanes
were installed, adding a little to the work, but contributing a good deal to our
sense of security. Once more, for the benefit of the landsman: The paravanes,
or PVs, are contrivances fitted to the bow of the ship, as a protection against
mines, so constructed that they will automatically pick up the moorings of a
mine and cut it adrift.
Beginning with our third trip, we worked on an express train schedule.
Everything depended upon speed. Our cargoes increased at the same time. In
addition to all kinds of army equipment, we frequently carried aeroplanes,
boats for overseas duty, and on one trip a large mooring buoy. In order to
load them on board, additional changes had to be made in the rigging,
purchases and guys of the booms. Even the weather decks were utilized for
the transportation of cargo for the naval forces overseas.
At the present writing the good old ship is still on the job—bringing them
back. The machine is running as smoothly as the ship’s engines, and instead
of having a few inexperienced men in the deck force, we have an
organization, built from almost nothing, that can compete with anything in the
navy.

Embarkation and Debarkation of Troops

W. S. A.
This is a brief description of how the Leviathan’s human cargo was loaded
and unloaded. The plan had been followed from the beginning with slight
changes made by experience in carrying troops over before the armistice and
carrying them back afterwards.
The ship’s troop capacity began at 6,800 and on the 13th voyage it was
approximately 12,000. Throughout the war it averaged about 10,000. In
addition, officers’ space has varied between 400 and 600.
Throughout the war, carrying troops east, five gangways were employed on
G-deck forward, to fill forward compartments; C-deck and F-decks amidships,
to fill amidship compartments; E-deck and G-deck gangways aft to fill after
compartments.
On each gangway, the compartment farthest away and lowest was filled
and so on to the gangway compartment. In no case did troops crowd through
a filled compartment.
It was early realized that loading the ship with troops was a Navy function
and was treated as such. The organization at each of the five gangways was:
one naval officer in charge and assisted by one chief petty officer and fifteen
men. Wherever Army officers were available one was detailed to assist the
Naval officer.
Prior to embarkation on each voyage, the ship’s embarkation officer made
an assignment of all troops the ship was to carry, so organizations would not
be split up but located in the same part of the ship to facilitate work. Often
this was a problem on account of the arrival of trains or ferries and the size of
organizations carried. Also, troop compartments had an arbitrary number of
bunks in them, based on the amount which could be put in and not upon the
number in military organizations. By planning we were able to get a complete
regiment amidships, one aft, and a battalion forward, then filling in smaller
units up to capacity.
Generally a battalion, or approximately 1,000 men, came to the ship a day
in advance of embarkation for the guard and mess details. The next day the
balance of the troops arrived. When the guard was not posted before
embarkation, the troops were all over decks, superstructure, and masts,
resulting in much unnecessary confusion.
Embarkation usually began about 8 o’clock or 9 o’clock in the morning,
although on one occasion it began as early as 5:30 A. M. Organizations
marched on the dock, both upper and lower levels, the Army checkers
checked the individual soldier’s names upon the passenger lists and the
soldier would receive a billet ticket which showed his compartment, bunk
number, deck space, abandon ship station, safety rules, etc. Then the column
would move over the gangway and the prescribed routes to the compartment.
Each of the five columns were led by a Naval guide, and other Naval guides
were posted along the route and seven or eight Navy men in the
compartment, to direct the columns to the proper bunks and put the soldiers
in the bunks called for by the billet tickets. The numbering in compartments
generally began in the forward starboard corner and ended in the after port
corner. Later on, the bunks in the amidship compartments were renumbered
so that a column of troops could be directed up a passageway and men could
get into the bunks on both sides of it.

Rules Observed
A company officer would go into the compartment being filled and assist
the Navy detail; troops got into their bunks as soon as found, and stayed
there until embarkation over that gangway was completed. No smoking was
allowed in compartments. Without strict adherence to these rules,
embarkation was hindered. Generally it was possible to take troops aboard
nearly as fast as they arrived on the dock and many times the dock would be
emptied before the next organizations would arrive. The troop mess hall on F-
deck was used as a reservoir to hold over 1,000 troops marching in a
serpentine line which proceeded into the compartments being filled. The
Naval officer in charge of the gangway circulated from the gangway over the
route into the compartment and saw that all went smoothly. The embarkation
officer moved around all gangways into compartments being filled and upon
the deck, generally overseeing and directing embarkation.
The Navy men for the forward gangway were from the first division,
midship gangways from the third division and the other gangways from the
fourth division. With the inborn aptitude of the American youth, they soon
became experts in embarking and made short work of filling compartments.
There was little change in the details during the entire war period. The men
took real pride in their work. Embarkation of 10,000 troops, each soldier into
his own numbered bunk, could not have been effected in a period of six to
eight hours, if it had not been for the zeal and ardor and intelligence which
the men put into their work.
Whenever a bunk was found which could not be used and compartments
were checked over before embarkation, the ticket was taken up from the
soldier and another secured at the gangway so the man could occupy a bunk
in the vicinity of his company.
Relations between the ship’s officers concerned with embarking and the
army officers of the port of embarkation staff were harmonious and co-
operation grew as trips increased. On some occasions the ship’s officers went
to the army camps, gave talks and distributed ship’s pamphlets in advance of
embarkation which were of assistance in embarking and getting the army
settled on board.
On these war time embarkations, one noted the eagerness with which the
troops came aboard to get to the scene of war. On one occasion a number of
colored troops went up E-deck gangway, which had an angle of nearly forty-
five degrees, upon their hands and knees for safety’s sake. This caused great
laughter.
Only on one or two embarkations were there any substantial delays, as
trains and ferries generally arrived on schedule. Once an entire regiment was
fitted up with two pairs of trench shoes upon the upper level of the dock.
During the influenza epidemic in the fall of 1918 taking the temperatures of all
troops slowed up embarkation.

Debarkations
During the war, debarkation on the first two trips to Liverpool was simply to
march the troops over the G-deck forward, F-deck amidships, and G-deck
after gangways on the landing stage in reverse order of embarkation, where
they mustered by organizations and entrained. On the third trip to Liverpool,
in November, 1918, the Leviathan ran her nose into the Mersey mud off the
Gladstone dock in a heavy fog. The tide ebbed and the ship began to list. All
the Mersey ferry boats were commandeered and the 8,000 troops were
debarked on them from F-deck gangway amidships and G-deck gangway aft,
in three hours. Gangways to the ferries in several cases were at an angle of
sixty degrees. Debarkation was rushed to lighten the ship, and she was
backed off on the rising tide that evening under her own power.
At Brest, during the war, a different plan was followed. Coaling began soon
after the ship was moored. G-deck gangways aft, port and starboard sides,
were the only gangways available to debark troops onto lighters. B-deck and
the troop mess hall were used as debarking mustering stations. Organizations
moved to them from their compartments, according to prearranged plan, as it
was essential to send the troops ashore by organizations. B-deck held about
1,800 men with their packs and the mess hall about 1,200. When assembled,
they moved to lighters lying at the after gangway. These held at first
according to size, from 600 to 2,200 men and they were packed tight. Their
capacity was reduced on later voyages.
The troops cheered the old Leviathan as their lighters drew away, and our
men responded. The Leviathan carried many organizations which later paid
heavy toll of casualties in battles.
When the armistice was signed and the westbound tide set in, it required
considerable work to reverse the procedure of embarking at Brest and
debarking at Hoboken. The entire embarkation was over G-deck gangway for
all compartments up to the thirteenth voyage, as it proceeded during coaling.
The procedure of filling compartments was the same, but it was necessary
to unload lighters quickly and get them away so the line of troops to
compartments was extended to fill A-deck, B-deck, D-deck forward and aft,
from whence the line of troops fed down into the compartments.
From 1,100 to 2,200 sick and wounded were embarked at the same time as
the other troops, this was done under supervision of the medical officer,
assisted by the hospital corps. The casuals were taken to sick bay or E-deck
compartments especially set aside for them.
Debarkation at Hoboken was the quick and happy event following the
reception the ship received coming up the harbor. G-deck forward, C and F-
decks amidships, and G-deck after gangways are used. The troops march out
on them in reverse order of embarking. Units muster on the dock according to
their organizations. Briefly, the procedure resembles pouring liquid out of
three different pitchers, just the reverse of filling the compartments upon
embarkation. The debarkation of troops was completed in about three hours.
The dock was always a lively place with throngs of reporters and welfare
workers present with refreshments and smokes for the boys. The canine
mascots generally got aboard unobserved, but in debarkation they proceed
with their proud masters down the gangways and are admired as returning
heroes by those upon the dock. Many of the dogs were “prisoners of war,”
having come over to the American trenches from the enemy.
Such, briefly, is the story of the loading and unloading of the Leviathan’s
human cargo. The doughboys have bravely done their part in winning the war.
We of the Leviathan have had the happy and important duty of getting them
over safely and bringing them back home.
Abandon Ship Drill

E. E.
Abandon ship drill is the most important drill on board ship as the saving of
the lives of all would depend upon the degree of perfection, organization, and
speed of execution. It is easily seen that a ship the size of the Leviathan by
reason of her water-tight doors would not sink for several hours after a
torpedo attack or after striking a mine; thus the great danger to be avoided is
the panic attendant upon such a contingency. The end to be attained is the
conducting of all the troops in an orderly and expeditious manner to the
weather decks where, equipped with life jackets and canteens, they can climb
over the side on sea ladders rigged for the purpose and reach the rafts and
boats already lowered into the water.
The abandon ship organization requires the second in army command to be
in charge of the troop movement. He has as his assistants thirty-five captains
as troop compartment officers—they are the senior officers in each troop
compartment—and seventy lieutenants, the junior compartment officers. As a
special abandon ship detail there are twelve majors acting as abandon ship
mustering station officers and twenty-four captains and lieutenants acting as
assistants to these officers.
The abandon ship mustering stations are distributed over the ship and
include all available space on the weather decks except such space as is
necessary to the lowering of boats or to the actual navigation of the ship. The
routing of the troops to these stations is worked out on the principle that all
watertight doors will be closed as soon as abandon ship signal sounds. The
capacity of these stations is limited to a minimum of three cubic feet of deck
space per man, giving also due consideration to the disposition of the ship’s
boats.
During the war the first abandon ship drill was held prior to the sailing of
the ship. All men aboard were obliged to keep their life jackets within reach at
all times. For the first three drills the troops were sent below to their
compartments at the call “assembly” on the bugles so they would become
familiar with their abandon ship route. After the first three drills, troops
already up on deck proceeded directly to their mustering stations.
Going to Bring the Doughboys Home

Troops were not required to wear their life jackets when hostilities ceased,
but when abandon ship drill was held they were sent below to assemble in
their compartments, put on their life jackets, and then at the abandon ship
call proceed over the abandon ship route to their mustering stations to stand
by for further orders or until “secure” is sounded.
The plan followed throughout the ship called for the emptying of the lowest
compartment first. Other compartments using the same abandon ship route
stand fast until the troops in the lowest compartment have filed past.
It was found that by this drill all compartments could be emptied and all
troops assembled at their abandon ship mustering stations within fifteen
minutes of the sounding of the abandon ship signal, or within one half hour of
the blowing of the “assembly” which sends the troops to their compartments.

The Gunnery Department


Gunnery Officers

Creed H. Boucher, Lieut., U.S.N.; assigned, August 3, 1917; detached,


April 20, 1918.
Arnold H. Bateman, Lieut., U.S.N.; assigned, April 20, 1918; detached,
October 27, 1918.
Charles K. Osborne, Lieut. Comdr., U.S.N.; assigned, October 27, 1918;
detached, April 3, 1919.

Assistant Gunnery Officers

William E. Malloy, Lieut., U.S.N.; assigned, October 8, 1917.

(Lieut. Malloy was detached as assistant Gunnery Officer in order to take


over the duties of First Lieutenant of the ship.)

Ship’s Gunners

Arthur B. Dorsey, Lieut., U.S.N.; assigned, July 30, 1917; detached,


January 22, 1919.
John T. Swift, Lieut., U.S.N.; assigned, January 22, 1919; detached,
March 6, 1919.
James F. Williams, Gunner, U.S.N.; assigned, January 20, 1919.

(Gunner Williams served on board as a Chief Gunner’s Mate from August,


1917, until he was made Gunner in January, 1919.)
Lieut. Boucher, Lieut. Malloy and Lieut. Dorsey, were the officers in charge
of the installation of the battery, fire control system, etc., the training of gun
crews and lookouts, and in fact all the numerous details required to have the
ship in readiness for sea and action when she cleared the net in New York
Harbor. Great credit is due these officers and the men of their department for
the excellent manner in which this work was carried out. Much credit is also
due the officers and men who succeeded them for the excellent manner in
which they maintained the high standard of efficiency that had been set for
them.
There were also six Chief Gunner’s Mates and seven gunner’s mates of
lower ratings attached to the ship during her voyages across the Atlantic.
No technical discussion of ordnance and gunnery will be attempted in these
pages, just a general description of guns, fire control systems, etc., and their
method of operation.

Armament and Equipment


The armament and equipment of the Leviathan consisted of the following:

8—6-inch 50-Cal. guns Mk. VIII.


2—1-Pdr. guns, Mk. VIII.
2—“Y”-Guns for throwing depth charges.
2—Colt Machine Guns.
1—Lewis Machine Gun.
150—.30-Cal. Springfield Rifles.
75—.45-Cal. Colt Automatic Pistols.
1—Large Bausch and Lomb 12-Ft. Range Finder.
2—Small Barr and Stroud 1-meter Range Finders.
1—Ford Range Keeper.

The six-inch guns were installed on October 5, 1917—four aft and four
forward. The distance between the forward and after guns was about seven
hundred feet, which is a greater distance than the entire length of any
battleship we have in commission.
The work of installation was carried on by ordnance men from the New York
Navy Yard, assisted by the ship’s gunnery department.
Splendid co-ordination existed at all times between the Navy Yard people
and the ship’s force which helped materially to expedite the work.
Considerable effort and labor were required to get the ship in readiness to
receive the guns, mounts, etc. Gun foundations and gun platforms had to be
built; blast bulkheads erected in proper places so as to protect one gun from
the fire of the other; certain portions of the deck were extended in order to
give the after guns a greater arc of train. Lines of communication, voice tubes
and telephones, had to be run from all guns to fire control and spotting
stations; and salvo bells and buzzers installed. All of this work was completed
in record time and gave excellent results throughout the war.
Foundation and mount tests were held on November 20, 1917, on our trial
trip to Guantanamo, when three shots were fired from each six-inch gun.
These tests proved satisfactory in every respect.
The 1-pdr. guns were not installed until September 28, 1918. These guns
were mounted on the port and starboard sides of C-deck amidships. They also
proved satisfactory when fired for tests on September 30, 1918. Lieutenant
Boucher originally made a request for four 1-pdr. guns and also two anti-
aircraft guns, but only the two 1-pdr. guns were allowed this ship.

Depth Charges
The original depth charge outfit of this vessel consisted of the earlier type
of depth charges, containing only fifty-two pounds of TNT as an explosive. We
were allowed ten of the charges and a chute was rigged over the stern for
launching them.
On July 27, 1918, two “Y” guns were installed which throw a charge of TNT
weighing 300 pounds. These were tested out by filling four large paint drums
with wet sand, to bring them up to the required weight, and firing them from
the “Y” guns. The cans landed approximately 200 feet from the ship, our extra
high freeboard causing them to travel farther than if fired from the deck of a
torpedo boat.
We never had the opportunity of trying our depth charges on a real
submarine. A ship of this size would have to be extremely lucky to manœuvre
so as to be in a position to drop a depth charge on a submarine.
The “Y”-guns were removed December 30, 1918, after the armistice had
been signed.

Machine Guns
The two Colt machine guns were mounted forward on C-deck gallery, abaft
No. 3 and No. 4 guns, and the Lewis machine gun aft by the depth charge
station. The primary object of the machine guns was for sinking floating
mines. The crews were kept in practice by firing at driftwood, floating boxes,
fish, etc. The 1-pdr. crews also engaged in this kind of practice.

Range Finders
The range finders were mounted on the forward superstructure just abaft
and above the signal bridge. The large range finder being mounted on a
specially constructed stand amidships between the port and starboard fire
control stations, and at a height of 124 feet above the water-line. Both control
stations were always within easy means of communication with this range
finder by means of voice tubes. The two small range-finders were mounted on
platforms—one on the outside of each fire control station.
It is difficult to use the range finder against a periscope for the simple
reason that the periscope is visible for only a short length of time, and is hard
to get a quick reading on. The range will have been obtained by spotting the
shots before the range finder can be brought into play. However, the range
finder would have been invaluable had we been attacked by a raider, or a
submarine on the surface.

Ammunition
The ammunition allowance for the ship was:

1,200—6-inch shells, long point.


1,200—6-inch 50-cal. powder charges.
80—6-inch flat nose shells. (Non-ricocheting, for submarines when
submerged.)
480—1-pdr. cartridges.
89,000—Cartridges, for .30-cal. rifle.
10,000—Cartridges, for .45-cal. automatic pistol.

In addition to the above, blank ammunition for rifles was carried for training
with ex-caliber.
Forty shells were carried in shell racks at the guns at all times, and twenty
rounds of powder at each gun while at sea. The rest of the ammunition was
carried in the magazines forward and aft (seven decks below) and supplied to
the guns by means of elevators and ammunition parties.

Gun Drills
Gun and fire control drills were held daily to keep all hands in practice.
These drills were discontinued while in the war zone. Actual conditions were
simulated as much as possible at all drills.

Gun Watches
When not in the war zone two guns forward (one on each side) and two
guns aft, were manned by a crew of six men at all times, with a man at the
telephones of each of the guns off watch. The men off watch had to remain in
the vicinity of their quarters ready for instant call.
While in the zone all guns were manned by a crew of six men with six men
standing by in reserve. The guns were kept loaded, both in and out of the
zone, with powder and shell—ready for instant firing by inserting a primer.

Lookouts
Good lookouts are absolutely essential to a ship’s safety. They have one of
the most important positions on the ship. On their alertness depends the
discovery of any submarine or suspicious object in his arc of lookout and the
immediate and accurate reporting of it to the fire control officer, so that the
guns may be brought into action in the quickest possible time against the
enemy.
There were twelve lookout stations on this vessel—six on each side—so
arranged that each lookout had an arc of thirty degrees to keep under close
observation. Of course there were additional lookouts on watch at all times,
such as the gun crews, control officers, signalmen and officers-of-the-deck.
Each tried to be the first to spot a hostile periscope.

Personnel
The personnel of the gun crews, lookouts, etc., showed excellent qualities
and sense of duty during the period of the war. In all attacks by submarines,
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