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

Download Full Introduction to Computing and Programming in Python, Global Edition Mark J. Guzdial PDF All Chapters

Guzdial

Uploaded by

gjetannwafor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
85 views

Download Full Introduction to Computing and Programming in Python, Global Edition Mark J. Guzdial PDF All Chapters

Guzdial

Uploaded by

gjetannwafor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Introduction to Computing and Programming in


Python, Global Edition Mark J. Guzdial

https://textbookfull.com/product/introduction-to-computing-
and-programming-in-python-global-edition-mark-j-guzdial/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

A Concise Introduction to Programming in Python Second


Edition Mark J. Johnson

https://textbookfull.com/product/a-concise-introduction-to-
programming-in-python-second-edition-mark-j-johnson/

textboxfull.com

Introduction to Scientific Programming with Python Joakim


Sundnes

https://textbookfull.com/product/introduction-to-scientific-
programming-with-python-joakim-sundnes/

textboxfull.com

Bite Size Python An Introduction to Python Programming 1st


Edition April Speight

https://textbookfull.com/product/bite-size-python-an-introduction-to-
python-programming-1st-edition-april-speight/

textboxfull.com

Introduction To Computing And Problem Solving Using Python


1st Edition E. Balaguruswamy

https://textbookfull.com/product/introduction-to-computing-and-
problem-solving-using-python-1st-edition-e-balaguruswamy/

textboxfull.com
Introduction to Computation and Programming Using Python
3rd Edition John V. Guttag

https://textbookfull.com/product/introduction-to-computation-and-
programming-using-python-3rd-edition-john-v-guttag/

textboxfull.com

Introduction to Computation and Programming Using Python


3rd Edition John V. Guttag

https://textbookfull.com/product/introduction-to-computation-and-
programming-using-python-3rd-edition-john-v-guttag-2/

textboxfull.com

Python Programming An Introduction to Computer Science


John M. Zelle

https://textbookfull.com/product/python-programming-an-introduction-
to-computer-science-john-m-zelle/

textboxfull.com

How to Design Programs An Introduction to Programming and


Computing Matthias Felleisen

https://textbookfull.com/product/how-to-design-programs-an-
introduction-to-programming-and-computing-matthias-felleisen/

textboxfull.com

Introduction to Computation and Programming Using Python


with Application to Understanding Data Guttag

https://textbookfull.com/product/introduction-to-computation-and-
programming-using-python-with-application-to-understanding-data-
guttag/
textboxfull.com
Introduction to
Computing and
Programming
TM
in Python
A MULTIMEDIA APPROACH

Mark J. Guzdial and Barbara Ericson


College of Computing/GVU
Georgia Institute of Technology

Fourth Edition
Global Edition

Boston Columbus Indianapolis New York San Francisco Hoboken


Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City São Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Vice President and Editorial Director, ECS: Marcia J. Horton Senior Manufacturing Controller, Global Edition: Kay Holman
Executive Editor: Tracy Johnson Media Production Manager, Global Edition: Vikram Kumar
Assistant Acquisitions Editor, Global Edition: Aditee Agarwal Global HE Director of Vendor Sourcing and Procurement: Diane Hynes
Executive Marketing Manager: Tim Galligan Director of Operations: Nick Sklitsis
Marketing Assistant: Jon Bryant Operations Specialist: Maura Zaldivar-Garcia
Senior Managing Editor: Scott Disanno Cover Designer: Lumina Datamatics
Production Project Manager: Greg Dulles Manager, Rights and Permissions: Rachel Youdelman
Program Manager: Carole Snyder Associate Project Manager, Rights and Permissions: Timothy Nicholls
Project Editor, Global Edition: K.K. Neelakantan Full-Service Project Management: Kalpana Arumugam, SPi Global

MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE INFORMATION
CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED AS PART OF THE SERVICES FOR ANY PURPOSE. ALL SUCH
DOCUMENTS AND RELATED GRAPHICS ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS
RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION,
INCLUDING ALL WARRANTIES AND CONDITIONS OF MERCHANTABILITY, WHETHER EXPRESS, IMPLIED OR STATUTORY, FITNESS
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL MICROSOFT AND/OR ITS RESPECTIVE
SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF INFORMATION AVAILABLE FROM THE SERVICES. THE
DOCUMENTS AND RELATED GRAPHICS CONTAINED HEREIN COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL
ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS
MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED HEREIN AT ANY TIME.
PARTIAL SCREEN SHOTS MAY BE VIEWED IN FULL WITHIN THE SOFTWARE VERSION SPECIFIED.

Pearson Education Limited


Edinburgh Gate
Harlow
Essex CM20 2JE
England

and Associated Companies throughout the world

Visit us on the World Wide Web at:


www.pearsonglobaleditions.com

© Pearson Education Limited 2016

The rights of Mark J. Guzdial and Barbara Ericson to be identified as the authors of this work have been asserted by them in accordance with the
Copyright, Designs and Patents Act 1988.

Authorized adaptation from the United States edition, entitled Introduction to Computing and Programming in Python™ : A Multimedia Approach, Fourth
Edition, ISBN 9780134025544, by Mark J. Guzdial and Barbara Ericson published by Pearson Education © 2016.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording or otherwise, without either the prior written permission of the publisher or a license permitting restricted copying in
the United Kingdom issued by the Copyright Licensing Agency Ltd, Saffron House, 6−10 Kirby Street, London EC1N 8TS.

All trademarks used herein are the property of their respective owners. The use of any trademark in this text does not vest in the author or publisher any
trademark ownership rights in such trademarks, nor does the use of such trademarks imply any affiliation with or endorsement of this book by such owners.

British Library Cataloguing-in-Publication Data

A catalogue record for this book is available from the British Library

10 9 8 7 6 5 4 3 2 1

ISBN 10: 1-292-10986-6


ISBN 13: 978-1-292-10986-2

Typeset in 10.5/13 Times by SPi Global


Printed and bound in Malaysia.
Dedicated to our first teachers, our parents:
Janet, Charles, Gene, and Nancy
This page intentionally left blank
Contents
Preface for the Fourth Edition 13
Preface to the First Edition 18
About the Authors 24

1 INTRODUCTION 25
1 Introduction to Computer Science and Media
Computation 27
1.1 What Is Computer Science About? 27
1.2 Programming Languages 30
1.3 What Computers Understand 33
1.4 Media Computation: Why Digitize Media? 35
1.5 Computer Science for Everyone 37
1.5.1 It’s About Communication 37
1.5.2 It’s About Process 37
1.5.3 You Will Probably Need It 38

2 Introduction to Programming 42
2.1 Programming Is About Naming 42
2.1.1 Files and Their Names 44
2.2 Programming in Python 45
2.3 Programming in JES 46
2.4 Media Computation in JES 47
2.4.1 Showing a Picture 51
2.4.2 Playing a Sound 54
2.4.3 Naming Values 54
2.5 Making a Program 57
2.5.1 Functions: Real Math-Like Functions That Take
Input 61
6 Contents

3 Creating and Modifying Text 68


3.1 Strings: Making Human Text in a Computer 68
3.1.1 Making Strings from Strings: Telling Stories 70
3.2 Taking Strings Apart with For 73
3.2.1 Testing the Pieces 75
3.2.2 Taking String Apart, and Putting Strings Together 78
3.2.3 Taking Strings Apart with Indices 81
3.2.4 Mirroring, Reversing, and Separating Strings with Index 83
3.2.5 Encoding and Decoding Strings Using a Keyword Cipher 85
3.3 Taking Strings Apart by Words 87
3.4 What’s Inside a String 90
3.5 What a Computer Can Do 91

4 Modifying Pictures Using Loops 98


4.1 How Pictures Are Encoded 99
4.2 Manipulating Pictures 104
4.2.1 Exploring Pictures 108
4.3 Changing Color Values 110
4.3.1 Using Loops in Pictures 110
4.3.2 Increasing/Decreasing Red (Green, Blue) 112
4.3.3 Testing the Program: Did That Really Work? 117
4.3.4 Changing One Color at a Time 118
4.4 Creating a Sunset 119
4.4.1 Making Sense of Functions 119
4.5 Lightening and Darkening 124
4.6 Creating a Negative 125
4.7 Converting to Grayscale 126
4.8 Specifying Pixels by Index 128

5 Picture Techniques with Selection 138


5.1 Replacing Colors: Red-Eye, Sepia Tones, and Posterizing 138
5.1.1 Reducing Red-Eye 142
5.1.2 Sepia-Toned and Posterized Pictures: Using
Conditionals to Choose the Color 144
5.2 Comparing Pixels: Edge Detection 150
5.3 Background Subtraction 153
5.4 Chromakey 156
5.5 Coloring in ranges 161
Contents 7

5.5.1 Adding a Border 161


5.5.2 Lightening the Right Half of a Picture 162
5.6 Selecting without Retesting 163

6 Modifying Pixels by Position 169


6.1 Processing Pixels Faster 169
6.1.1 Looping across the Pixels with Range 171
6.1.2 Writing Faster Pixel Loops 173
6.2 Mirroring a Picture 175
6.3 Copying and Transforming Pictures 182
6.3.1 Copying 183
6.3.2 Copying Smaller and Modifying 189
6.3.3 Copying and Referencing 191
6.3.4 Creating a Collage 193
6.3.5 General Copying 196
6.3.6 Rotation 197
6.3.7 Scaling 200
6.4 Combining Pixels: Blurring 205
6.5 Blending Pictures 208
6.6 Drawing on Images 210
6.6.1 Drawing with Drawing Commands 212
6.6.2 Vector and Bitmap Representations 213
6.7 Programs as Specifying Drawing Process 215
6.7.1 Why Do We Write Programs? 216

2 SOUND 225
7 Modifying Sounds Using Loops 227
7.1 How Sound Is Encoded 227
7.1.1 The Physics of Sound 227
7.1.2 Investigating Different Sounds 230
7.1.3 Encoding the Sound 235
7.1.4 Binary Numbers and Two’s Complement 236
7.1.5 Storing Digitized Sounds 237
7.2 Manipulating Sounds 239
7.2.1 Open Sounds and Manipulating Samples 239
7.2.2 Using the JES MediaTools 242
7.2.3 Looping 243
7.3 Changing the Volume of Sounds 244
8 Contents

7.3.1 Increasing Volume 244


7.3.2 Did That Really Work? 245
7.3.3 Decreasing Volume 249
7.3.4 Using Array Index Notation 250
7.3.5 Making Sense of Functions in Sounds 251
7.4 Normalizing Sounds 251
7.4.1 Generating Clipping 253

8 Modifying Samples in a Range 259


8.1 Manipulating Different Sections of the Sound Differently 259
8.1.1 Revisiting Index Array Notation 260
8.2 Splicing Sounds 262
8.3 General Clip and Copy 269
8.4 Reversing Sounds 271
8.5 Mirroring 273
8.6 On Functions and Scope 273

9 Making Sounds by Combining Pieces 279


9.1 Composing Sounds Through Addition 279
9.2 Blending Sounds 280
9.3 Creating an Echo 282
9.3.1 Creating Multiple Echoes 284
9.3.2 Creating Chords 284
9.4 How Sampling Keyboards Work 285
9.4.1 Sampling as an Algorithm 289
9.5 Additive Synthesis 289
9.5.1 Making Sine Waves 289
9.5.2 Adding Sine Waves Together 291
9.5.3 Checking Our Result 292
9.5.4 Square Waves 293
9.5.5 Triangular Waves 295
9.6 Modern Music Synthesis 297
9.6.1 MP3 297
9.6.2 MIDI 298

10 Building Bigger Programs 302


10.1 Designing Programs Top-Down 303
10.1.1 A Top-Down Design Example 304
10.1.2 Designing the Top-Level Function 305
10.1.3 Writing the Subfunctions 307
Contents 9

10.2 Designing Programs Bottom-Up 311


10.2.1 An Example Bottom-Up Process 312
10.3 Testing Your Program 312
10.3.1 Testing the Edge Conditions 314
10.4 Tips on Debugging 315
10.4.1 Finding Which Statement to Worry About 316
10.4.2 Seeing the Variables 316
10.4.3 Debugging the Adventure Game 318
10.5 Algorithms and Design 321
10.6 Connecting to Data Outside a Function 322
10.7 Running Programs Outside of JES 326

3 TEXT, FILES, NETWORKS, DATABASES,


AND UNIMEDIA 333
11 Manipulating Text with Methods and Files 335
11.1 Text as Unimedia 335
11.2 Manipulating Parts of Strings 336
11.2.1 String Methods: Introducing Objects and Dot Notation 337
11.2.2 Lists: Powerful, Structured Text 339
11.2.3 Strings Have No Font 341
11.3 Files: Places to Put Your Strings and Other Stuff 341
11.3.1 Opening and Manipulating Files 343
11.3.2 Generating Form Letters 344
11.3.3 Reading and Manipulating Data from the Internet 345
11.3.4 Scraping Information from a Web Page 348
11.3.5 Reading CSV Data 349
11.3.6 Writing Out Programs 351
11.4 The Python Standard Library 352
11.4.1 More on Import and Your Own Modules 353
11.4.2 Adding Unpredictably to Your Program with Random 354
11.4.3 Reading CSV Files with a Library 356
11.4.4 A Sampling of Python Standard Libraries 356

12 Advanced Text Techniques: Web


and Information 361
12.1 Networks: Getting Our Text from the Web 361
12.1.1 Automating Access to CSV Data 365
12.1.2 Accessing FTP 367
10 Contents

12.2 Using Text to Shift Between Media 368


12.3 Moving Information Between Media 371
12.4 Using Lists as Structured Text for Media Representations 374
12.5 Hiding Information in a Picture 375
12.5.1 Hiding a Sound Inside a Picture 377

13 Making Text for the Web 383


13.1 HTML: The Notation of the Web 383
13.2 Writing Programs to Generate HTML 388
13.2.1 Making Home Pages 390
13.3 Databases: A Place to Store Our Text 393
13.3.1 Relational Databases 395
13.3.2 An Example Relational Database Using Hash Tables 396
13.3.3 Working with SQL 399
13.3.4 Using a Database to Build Web Pages 401

4 MOVIES 407
14 Creating and Modifying Movies 409
14.1 Generating Animations 410
14.2 Working with Video Source 419
14.2.1 Video Manipulating Examples 419
14.3 Building a Video Effect Bottom-Up 423

15 Speed 430
15.1 Focusing on Computer Science 430
15.2 What Makes Programs Fast? 430
15.2.1 What Computers Really Understand 431
15.2.2 Compilers and Interpreters 432
15.2.3 What Limits Computer Speed? 436
15.2.4 Does It Really Make a Difference? 438
15.2.5 Making Searching Faster 441
15.2.6 Algorithms That Never Finish or Can’t Be Written 443
15.2.7 Why Is Photoshop Faster than JES? 444
15.3 What Makes a Computer Fast? 444
15.3.1 Clock Rates and Actual Computation 445
15.3.2 Storage: What Makes a Computer Slow? 446
15.3.3 Display 447
Contents 11

16 Functional Programming 450


16.1 Using Functions to Make Programming Easier 450
16.2 Functional Programming with Map and Reduce 454
16.3 Functional Programming for Media 457
16.3.1 Media Manipulation without Changing State 458
16.4 Recursion: A Powerful Idea 459
16.4.1 Recursive Directory Traversals 464
16.4.2 Recursive Media Functions 466

17 Object-Oriented Programming 471


17.1 History of Objects 471
17.2 Working with Turtles 473
17.2.1 Classes and Objects 473
17.2.2 Sending Messages to Objects 474
17.2.3 Objects Control Their State 476
17.3 Teaching Turtles New Tricks 478
17.3.1 Overriding an Existing Turtle Method 480
17.3.2 Working with Multiple Turtles at Once 481
17.3.3 Turtles with Pictures 483
17.3.4 Dancing Turtles 484
17.3.5 Recursion and Turtles 487
17.4 An Object-Oriented Slide Show 488
17.4.1 Making the Slide Class More Object-Oriented 491
17.5 Object-Oriented Media 493
17.6 Joe the Box 498
17.7 Why Objects? 499

APPENDIX 506
A Quick Reference to Python 506
A.1 Variables 506
A.2 Function Creation 507
A.3 Loops and Conditionals 507
A.4 Operators and Representation Functions 508
A.5 Numeric Functions 509
A.6 Sequence Operations 509
A.7 String Escapes 509
12 Contents

A.8 Useful String Methods 509


A.9 Files 510
A.10 Lists 510
A.11 Dictionaries, Hash Tables, or Associative Arrays 510
A.12 External Modules 510
A.13 Classes 511
A.14 Functional Methods 511

Bibliography 512

Index 515
Preface for the
Fourth Edition
We started Media Computation in the of Summer 2002, and taught it for the first time
in Spring 2003. It’s now over ten years later, which is a good time to summarize the
changes across the second, third, and fourth editions.
Media Computation has been used successfully in an undergraduate course at Geor-
gia Tech for the last dozen years. The course continues to have high retention rates (over
85% of students complete the class with a passing grade), and is majority female. Both
students and teachers report enjoying the course, which is an important recommendation
for it.
Researchers have found that Media Computation works in a variety of contexts.
The University of Illinois-Chicago had the first Media Computation paper outside of
Georgia, and they showed how switching to MediaComp improved their retention
rates in classes that were much more diverse than those at Georgia Tech [41]. The
University of California-San Diego adopted Media Computation as part of a big change
in their introductory course, where they also started using pair-programming and peer
instruction. Their paper at the 2013 SIGCSE Symposium showed how these changes
led to dramatic improvements in student retention, even measured a year later in the
Sophomore year. The paper also won the Best Paper award at the conference [27].
It’s been particularly delightful to see Media Computation adopted and adapted for
new settings, like Cynthia Bailey Lee’s creation of a MATLAB Media Computation
curriculum [12].
Mark wrote a paper in 2013, summarizing ten years of Media Computation research.
Media Computation does often improve retention. Our detailed interview studies with
female students supports the claim that they find the approach to be creative and engag-
ing, and that’s what keeps the students in the class. That paper won the Best Paper award
at the 2013 International Computing Education Research (ICER) Conference [33].

HOW TO TEACH MEDIA COMPUTATION


Over the last 10 years, we have learned some of the approaches that work best for
teaching Media Computation.

• Let the students be creative. The most successful Media Computation classes
use open-ended assignments that let the students choose what media they use.
For example, a collage assignment might specify the use of particular filters and
compositions, but allow for the student to choose exactly what pictures are used.
These assignments often lead to the students putting in a lot more time to get just
the look that they wanted, and that extra time can lead to improved learning.
14 Preface for the Fourth Edition

• Let the students share what they produce. Students can produce some beautiful
pictures, sounds, and movies using Media Computation. Those products are more
motivating for the students when they get to share them with others. Some schools
provide online spaces where students can post and share their products. Other
schools have even printed student work and held an art gallery.
• Code live in front of the class. The best part of the teacher actually typing in code
in front of the class is that nobody can code for long in front of an audience and
not make a mistake. When the teacher makes a mistake and fixes it, the students
see (a) that errors are expected and (b) there is a process for fixing them. Coding
live when you are producing images and sounds is fun, and can lead to unexpected
results and the opportunity to explore, “How did that happen?”
• Pair programming leads to better learning and retention. The research results on
pair programming are tremendous. Classes that use pair programming have better
retention results, and the students learn more.
• Peer instruction is great. Not only does peer instruction lead to better learning
and retention outcomes, but it also gives the teacher better feedback on what the
students are learning and what they are struggling with. We strongly encourage
the use of peer instruction in computing classes.
• Worked examples help with creativity learning. Most computer science classes
do not provide anywhere nearly enough worked-out examples for students to
learn from. Students like to learn from examples. One of the benefits of Media
Computation is that we provide a lot of examples (we’ve never tried to count the
number of for and if statements in the book!), and it’s easy to produce more
of them. In class, we do an activity where we hand out example programs, then
show a particular effect. We ask pairs or groups of students to figure out which
program generated that effect. The students talk about code, and study a bunch of
examples.

AP CS PRINCIPLES
The Advanced Placement exam in CS Principles1 has now been defined. We have
explicitly written the fourth edition with CS Principles in mind. For example, we show
how to measure the speed of a program empirically in order to contrast two algorithms
(Learning Objective 4.2.4), and we explore multiple ways of analyzing CSV data from
the Internet (Learning Objectives 3.1.1, 3.2.1, and 3.2.2).
Overall, we address the CS Principles learning objectives explicitly in this book as
shown below:
• In Big Idea I: Creativity:
• LO 1.1.1: . . . use computing tools and techniques to create artifacts.
• LO 1.2.1: . . . use computing tools and techniques for creative expression.
1
http://apcsprinciples.org
Preface for the Fourth Edition 15

• LO 1.2.2: . . . create a computational artifact using computing tools and techniques


to solve a problem.
• LO 1.2.3: . . . create a new computational artifact by combining or modifying
existing artifacts.
• LO 1.2.5: . . . analyze the correctness, usability, functionality, and suitability of
computational artifacts.
• LO 1.3.1: . . . use programming as a creative tool.
• In Big Idea II: Abstraction:
• LO 2.1.1: . . . describe the variety of abstractions used to represent data.
• LO 2.1.2: . . . explain how binary sequences are used to represent digital data.
• LO 2.2.2: . . . use multiple levels of abstraction in computation.
• LO 2.2.3: . . . identify multiple levels of abstractions being used when writing
programs.
• In Big Idea III: Data and information:
• LO 3.1.1: . . . use computers to process information, find patterns, and test
hypotheses about digitally processed information to gain insight and knowledge.
• LO 3.2.1: . . . extract information from data to discover and explain connections,
patterns, or trends.
• LO 3.2.2: . . . use large data sets to explore and discover information and knowl-
edge.
• LO 3.3.1: . . . analyze how data representation, storage, security, and transmission
of data involve computational manipulation of information.
• In Big Idea IV: Algorithms:
• LO 4.1.1: . . . develop an algorithm designed to be implemented to run on a
computer.
• LO 4.1.2: . . . express an algorithm in a language.
• LO 4.2.1: . . . explain the difference between algorithms that run in a reasonable
time and those that do not run in a reasonable time.
• LO 4.2.2: . . . explain the difference between solvable and unsolvable problems
in computer science.
• LO 4.2.4: . . . evaluate algorithms analytically and empirically for efficiency,
correctness, and clarity.
• In Big Idea V: Programming:
• LO 5.1.1: . . . develop a program for creative expression, to satisfy personal
curiosity or to create new knowledge.
• LO 5.1.2: . . . develop a correct program to solve problems.
• LO 5.2.1: . . . explain how programs implement algorithms.
• LO 5.3.1: . . . use abstraction to manage complexity in programs.
16 Preface for the Fourth Edition

• LO 5.5.1: . . . employ appropriate mathematical and logical concepts in program-


ming.
• In Big Idea VI: The Internet:
• LO 6.1.1: . . . explain the abstractions in the Internet and how the Internet func-
tions.

CHANGES IN THE FOURTH EDITION


1. We fixed lots of bugs that our crack bug-finders identified in the third edition.
2. We changed most of the pictures in the book – they were getting stale, and our kids
wanted us to not use as many pictures of them.
3. We added more end-of-chapter questions.
4. We added a whole new chapter, on text as a medium and manipulating strings
(to make sentences, koans, and codes). This isn’t a necessary chapter (e.g., we
introduce for and if statements, but we didn’t remove the introductions later in
the book). For some of our teachers, playing with text with shorter loops (iterating
over all the characters in a sentence is typically smaller than the thousands of pixels
in a picture) is a more comfortable way to start.
5. We gave up fighting the battle of inventing a Web scraper that could beat out the
changes that Facebook made, which kept breaking the one we put in the 3rd edition
and then kept updating on the teacher’s website2 . Instead, we wrote examples in
this book for processing CSV (Comma-Separated Values), a common format for
sharing data on the Internet. We parse the CSV from a file using string processing,
then using the CSV library in Python, and then accessing the data by URL.
6. We added some new edge detection code which is shorter and simpler to understand.
7. We added more with turtles: creating dancing turtles (using sleep from the time
module to pause execution) and recursive patterns.
8. We updated the book to use the latest features in JES, which include those that
reduce the need to use full pathnames (a problem identified by Stephen Edwards
and his students in their SIGCSE 2014 paper [43]).

ACKNOWLEDGMENTS
Our sincere thanks go out to all our reviewers and bug-finders:
• At the top of the list is Susan Schwarz of the US Military Academy at West Point.
Susan runs a large course with many instructors, and pays careful attention to
what’s going in all of the sections of the course. She turned that attention on
the third edition of this book. She caught many bugs, and gave us lots of useful
feedback. Thanks, Susan!
2
http://home.cc.gatech.edu/mediaComp and http://www.mediacomputation.org
Preface for the Fourth Edition 17

• Our other bug finders for the book were John Rutkiewicz, U. Massachusetts–
Dartmouth; Brian Dorn, U. Nebraska–Omaha; Dave Largent, Ball State Univer-
sity; Simon, University of Newcastle; Eva Heinrich, Massey University; Peter
J. DePasquale, The College of New Jersey, and Bill Leahy, Georgia Institute of
Technology.
• Matthew Frazier, North Carolina State University, worked with us in the summer
of 2014 to create a new version of JES – fixing many bugs, and improving JES
considerably.
• We are grateful for the feedback from our book reviewers for the 4th edition:
Andrew Cencini, Bennington College; Susan Fox, Macalester College; Kristin
Lamberty, University of Minnesota-Morris; Jean Smith, Technical College of the
Lowcountry; and William T. Verts, University of Massachusetts-Amherst.
• We are grateful for the input from our book reviewers for the 3rd edition, too:
Joseph Oldham, Centre College; Lukasz Ziarek, Purdue University;Joseph
O’Rourke, Smith College; Atul Prakash, University of Michigan; Noah D. Bar-
nette, Virginia Tech; Adelaida A. Medlock, Drexel University; Susan E. Fox,
Macalester College; Daniel G. Brown, University of Waterloo; Brian A. Malloy,
Clemson University; Renee Renner, California State University, Chico.

Mark Guzdial and Barbara Ericson


Georgia Institute of Technology
Preface to the First Edition
Research in computing education makes it clear that one doesn’t just “learn to program.”
One learns to program something [8, 19], and the motivation to do that something can
make the difference between learning and not learning to program [5]. The challenge
for any teacher is to pick a something that is a powerful enough motivator.
People want to communicate. We are social creatures and the desire to communicate
is one of our primal motivations. Increasingly, the computer is used as a tool for com-
munication even more than a tool for calculation. Virtually all published text, images,
sounds, music, and movies today are prepared using computing technology.
This book is about teaching people to program in order to communicate with digital
media. The book focuses on how to manipulate images, sounds, text, and movies as
professionals might, but with programs written by students. We know that most people
will use professional-grade applications to perform these type of manipulations. But,
knowing how to write your own programs means that you can do more than what your
current application allows you to do. Your power of expression is not limited by your
application software.
It may also be true that knowing how the algorithms in a media applications work
allows you to use them better or to move from one application to the next more easily.
If your focus in an application is on what menu item does what, every application is
different. But if your focus is on moving or coloring the pixels in the way you want,
then maybe it’s easier to get past the menu items and focus on what you want to say.
This book is not just about programming in media. Media-manipulation programs
can be hard to write or may behave in unexpected ways. Natural questions arise, like
“Why is the same image filter faster in Photoshop?” and “That was hard to debug—Are
there ways of writing programs that are easier to debug?” Answering questions like
these is what computer scientists do. There are several chapters at the end of the book
that are about computing, not just programming. The final chapters go beyond media
manipulation to more general topics.
The computer is the most amazingly creative device that humans have ever conceived.
It is completely made up of mind-stuff. The notion “Don’t just dream it, be it” is really
possible on a computer. If you can imagine it, you can make it “real” on the computer.
Playing with programming can be and should be enormous fun.

OBJECTIVES, APPROACH AND ORGANIZATION


The curricular content of this book meets the requirements of the “imperative-first”
approach described in the ACM/IEEE Computing Curriculum 2001 standards document
[2]. The book starts with a focus on fundamental programming constructs: assignments,
sequential operations, iteration, conditionals, and defining functions. Abstractions
Preface to the First Edition 19

(e.g., algorithmic complexity, program efficiency, computer organization, hierarchi-


cal decomposition, recursion, and object-oriented programming) are emphasized later,
after the students have a context for understanding them.
This unusual ordering is based on the findings of research in the learning sciences.
Memory is associative. We remember new things based on what we associate them with.
People can learn concepts and skills on the premise that they will be useful some day but
the concepts and skills will be related only to the premises. The result has been described
as “brittle knowledge” [25]—the kind of knowledge that gets you through the exam
but is promptly forgotten because it doesn’t relate to anything but being in that class.
Concepts and skills are best remembered if they can be related to many different
ideas or to ideas that come up in one’s everyday life. If we want students to gain
transferable knowledge (knowledge that can be applied in new situations), we have to
help them to relate new knowledge to more general problems, so that the memories get
indexed in ways that associate with those kinds of problems [22]. In this book, we teach
with concrete experiences that students can explore and relate to (e.g., conditionals for
removing red-eye in pictures) and later lay abstractions on top of them (e.g., achieving
the same goal using recursion or functional filters and maps).
We know that starting from the abstractions doesn’t really work for computing
students. Ann Fleury has shown that students in introductory computing courses just
don’t buy what we tell them about encapsulation and reuse (e.g., [7]). Students prefer
simpler code that they can trace easily and they actually think that such code is better.
It takes time and experience for students to realize that there is value in well-designed
systems. Without experience, it’s very difficult for students to learn the abstractions.
The media computation approach used in this book starts from what many people
use computers for: image manipulation, exploring digital music, viewing and creating
Web pages, and making videos. We then explain programming and computing in terms
of these activities. We want students to visit Amazon (for example) and think, “Here’s
a catalog Web site—and I know that these are implemented with a database and a
set of programs that format the database entries as Web pages.” We want students to
use Adobe Photoshop and GIMP and think about how their image filters are actually
manipulating red, green, and blue components of pixels. Starting from a relevant context
makes transfer of knowledge and skills more likely. It also makes the examples more
interesting and motivating, which helps with keeping students in the class.
The media computation approach spends about two-thirds of the time on giving
students experiences with a variety of media in contexts that they find motivating. After
that two-thirds, though, they naturally start to ask questions about computing. “Why is
it that Photoshop is faster than my program?” and “Movie code is slow—How slow do
programs get?” are typical. At that point, we introduce the abstractions and the valuable
insights from computer science that answer their questions. That’s what the last part
of this book is about.
A different body of research in computing education explores why withdrawal or
failure rates in introductory computing are so high. One common theme is that com-
puting courses seem “irrelevant” and unnecessarily focus on “tedious details” such
as efficiency [21, 1]. A communications context is perceived as relevant by students
20 Preface to the First Edition

(as they tell us in surveys and interviews [6, 18]). The relevant context is part of the
explanation for the success we have had with retention in the Georgia Tech course for
which this book was written.
The late entrance of abstraction isn’t the only unusual ordering in this approach. We
start using arrays and matrices in Chapter 3, in our first significant programs. Typically,
introductory computing courses push arrays off until later, because they are obviously
more complicated than variables with simple values. A relevant and concrete context
is very powerful [19]. We find that students have no problem manipulating matrices of
pixels in a picture.
The rate of students withdrawing from introductory computing courses or receiving
a D or F grade (commonly called the WDF rate) is reported in the 30–50% range or
even higher. A recent international survey of failure rates in introductory computing
courses reported that the average failure rate among 54 U.S. institutions was 33% and
among 17 international institutions was 17% [24]. At Georgia Tech, from 2000 to 2002,
we had an average WDF rate of 28% in the introductory course required for all majors.
We used the first edition of this text in our course Introduction to Media Computation.
Our first pilot offering of the course had 121 students, no computing or engineering
majors, and two-thirds of the students were female. Our WDF rate was 11.5%.
Over the next two years (Spring 2003 to Fall 2005), the average WDF rate at Georgia
Tech (across multiple instructors, and literally thousands of students) was 15% [29].
Actually, the 28% prior WDF rate and 15% current WDF rate are incomparable, since
all majors took the first course and only liberal arts, architecture, and management
majors took the new course. Individual majors have much more dramatic changes.
Management majors, for example, had a 51.5% WDF rate from 1999 to 2003 with the
earlier course, and had a 11.2% failure rate in the first two years of the new course [29].
Since the first edition of this book was published, several other schools have adopted
and adapted this approach and evaluated their result. All of them have reported similar,
dramatic improvements in success rates [4, 42].

Ways to Use This Book


This book represents what we teach at Georgia Tech in pretty much the same order.
Individual teachers may skip some sections (e.g., the section on additive synthesis,
MIDI, and MP3), but all of the content here has been tested with our students.
However, this material has been used in many other ways.
• A short introduction to computing could be taught with just Chapters 2 (intro-
duction to programming) and 3 (introduction to image processing), perhaps with
some material from Chapters 4 and 5. We have taught even single-day workshops
on media computation using just this material.
• Chapters 6 through 8 basically replicate the computer science concepts from
Chapters 3 through 5 but in the context of sounds rather than images. We find
the replication useful—some students seem to relate better to the concepts of
iteration and conditionals when working with one medium than with the other.
Preface to the First Edition 21

Further, it gives us the opportunity to point out that the same algorithm can have
similar effects in different media (e.g., scaling a picture up or down and shifting a
sound higher or lower in pitch are the same algorithm). But it could certainly be
skipped to save time.
• Chapter 12 (on movies) introduces no new programming or computing concepts.
While motivational, movie processing could be skipped to save time.
• We recommend getting to at least some of the chapters in the last unit, in order to
lead students into thinking about computing and programming in a more abstract
manner, but clearly not all of the chapters have to be covered.

Python and Jython


The programming language used in this book is Python. Python has been described as
“executable pseudo-code.” We have found that both computer science majors and non
majors can learn Python. Since Python is actually used for communications tasks (e.g.,
Web site development), it’s a relevant language for an introductory computing course.
For example, job advertisements posted to the Python Web site (http://www.python.
org) show that companies like Google and Industrial Light & Magic hire Python pro-
grammers.
The specific dialect of Python used in this book is Jython (http://www.jython.
org). Jython is Python. The differences between Python (normally implemented in C)
and Jython (which is implemented in Java) are akin to the differences between any
two language implementations (e.g., Microsoft vs. GNU C++ implementations)—the
basic language is exactly the same, with some library and details differences that most
students will never notice.

TYPOGRAPHICAL NOTATIONS
Examples of Python code look like this: x = x + 1. Longer examples look like this:
def helloWorld():
print "Hello, world!"

When showing something that the user types in with Python’s response, it will have
a similar font and style, but the user’s typing will appear after a Python prompt (>>>):
>>> print 3 + 4
7

User interface components of JES (Jython Environment for Students) will be spec-
ified using a small caps font, like Save menu item and the Load button.
There are several special kinds of sidebars that you’ll find in the book.

Computer Science Idea: An Example Idea


Key computer science concepts appear like this.

22 Preface to the First Edition

Common Bug: An Example Common Bug


Common things that can cause your program to fail appear like this.


Debugging Tip: An Example Debugging Tip


If there’s a good way to keep a bug from creeping into your programs in the first place,
it’s highlighted here.


Making It Work Tip: An Example How to Make It Work


Best practices or techniques that really help are highlighted like this.


INSTRUCTOR RESOURCES
The instructor resources are available on the Pearson Education’s Instructor Resource
Center at www.pearsonglobaleditions.com/guzdial:
• PowerPoint Presentation slides

ACKNOWLEDGMENTS
Our sincere thanks go out to the following:
• Jason Ergle, Claire Bailey, David Raines, and Joshua Sklare, who made the initial
version of JES with surprising quality in an amazingly short amount of time. Over
the years, Adam Wilson, Larry Olson, Yu Cheung (Toby) Ho, Eric Mickley, Keith
McDermott, Ellie Harmon, Timmy Douglas, Alex Rudnick, Brian O’Neill, and
William Fredrick (Buck) Scharfnorth III have made JES into the useful and still
understandable tool that it is today.
• Adam Wilson built the MediaTools that are so useful for exploring sounds and
images and processing video.
• Andrea Forte, Mark Richman, Matt Wallace, Alisa Bandlow, Derek Chambless,
Larry Olson, and David Rennie helped build course materials. Derek, Mark, and
Matt created many example programs.
• There were several people who really made the effort come together at Georgia
Tech. Bob McMath, Vice-Provost at Georgia Tech, and Jim Foley, Associate Dean
for Education in the College of Computing, invested in this effort early on. Kurt
Eiselt worked hard to make this effort real, convincing others to take it seriously.
Janet Kolodner and Aaron Bobick were excited and encouraging about the idea
of media computation for students new to computer science. Jeff Pierce reviewed
Preface to the First Edition 23

and advised us on the design of the media functions used in the book. Aaron
Lanterman gave me lots of advice on how to convey the digital material content
accurately. Joan Morton, Chrissy Hendricks, David White, and all the staff of the
GVU Center made sure that we had what we needed and that the details were
handled to make this effort come together. Amy Bruckman and Eugene Guzdial
bought Mark time to get the final version completed.
• We are grateful to Colin Potts and Monica Sweat who have taught this class at
Georgia Tech and given us many insights about the course.
• Charles Fowler was the first person outside of Georgia Tech willing to take the
gamble and trial the course in his own institution (Gainesville College), for which
we’re very grateful.
• The pilot course offered in Spring 2003 at Georgia Tech was very important in
helping us improve the course. Andrea Forte, Rachel Fithian, and Lauren Rich did
the assessment of the pilot offering of the course, which was incredibly valuable in
helping us understand what worked and what didn’t. The first teaching assistants
(Jim Gruen, Angela Liang, Larry Olson, Matt Wallace, Adam Wilson, and Jose
Zagal) did a lot to help create this approach. Blair MacIntyre, Colin Potts, and
Monica Sweat helped make the materials easier for others to adopt. Jochen Rick
made the CoWeb/Swiki a great place for CS1315 students to hang out.
• Many students pointed out errors and made suggestions to improve the book.
Thanks to Catherine Billiris, Jennifer Blake, Karin Bowman, Maryam Doroudi,
Suzannah Gill, Baillie Homire, Jonathan Laing, Mireille Murad, Michael Shaw,
Summar Shoaib, and especially Jonathan Longhitano, who has a real flair for
copyediting.
• Thanks to former Media Computation students Constantino Kombosch, Joseph
Clark, and Shannon Joiner for permission to use their snapshots from class in
examples.
• The research work that led to this text was supported by grants from the National
Science Foundation—from the Division of Undergraduate Education, CCLI pro-
gram, and from the CISE Educational Innovations program. Thank you for the
support.
• Thanks to computing students Anthony Thomas, Celines Rivera, and Carolina
Gomez for allowing us to use their pictures.
• Finally but most important, thanks to our children Matthew, Katherine, and Jennifer
Guzdial, who allowed themselves to be photographed and recorded for Mommy
and Daddy’s media project and who were supportive and excited about the class.

Mark Guzdial and Barbara Ericson


Georgia Institute of Technology
Pearson would like to thank and acknowledge Dheeraj D., REVA Institute of Technol-
ogy and Management Kattigenahalli, Somitra Sanadhya, Indian Institute of Technology
Delhi, and Simon, University of Newcastle, for contributing to the Global Edition, and
Shaligram Prajapat, Devi Ahilya University Indore, Ng Hu, Multimedia University,
Rohit Tahiliani, Renjith S., and Shivani Pandit, for reviewing the Global Edition.
About the Authors
Mark Guzdial is a professor in the School of Interactive Computing in the College
of Computing at Georgia Institute of Technology. He is one of the founders of the
ACM’s International Computing Education Research workshop series. Dr. Guzdial’s
research focuses on learning sciences and technology, specifically, computing education
research. His first books were on the programming language Squeak and its use in
education. He was the original developer of “Swiki” (Squeak Wiki), the first wiki
developed explicitly for use in schools. He is a Fellow and a Distinguished Educator
of the ACM. He is on the editorial boards of the Journal of the Learning Sciences and
Communications of the ACM. He was a recipient of the 2012 IEEE Computer Society
Undergraduate Teaching Award.
Barbara Ericson is a research scientist and the director of Computing Outreach for
the College of Computing at Georgia Tech. She has been working on improving intro-
ductory computing education since 2004.
She has served as the teacher education representative on the Computer Science
Teachers Association board, the co-chair of the K-12 Alliance for the National Center
for Women in Information Technology, and as a reader for the Advanced Placement
Computer Science exams. She enjoys the diversity of the types of problems she has
worked on over the years in computing including computer graphics, artificial intelli-
gence, medicine, and object-oriented programming.
Mark and Barbara received the 2010 ACM Karl V. Karlstrom Award for Outstanding
Computer Educator for their work on Media Computation including this book. They led
a project called “Georgia Computes!” for six years, which had a significant impact in
improving computing education in the US state of Georgia [31]. Together, they Mark
and Barbara are leaders in the Expanding Computing Education Pathways (ECEP)
alliance3

3
http://www.ecepalliance.org
PART

1 INTRODUCTION

Chapter 1 Introduction to Computer Science


and Media Computation
Chapter 2 Introduction to Programming
Chapter 3 Creating and Modifying Text
Chapter 4 Modifying Pictures Using Loops
Chapter 5 Picture Techniques with Selection
Chapter 6 Modifying Pixels by Position
This page intentionally left blank
CHAPTER
Introduction

1 to Computer Science
and Media Computation
1.1 WHAT IS COMPUTER SCIENCE ABOUT?

1.2 PROGRAMMING LANGUAGES

1.3 WHAT COMPUTERS UNDERSTAND

1.4 MEDIA COMPUTATION: WHY DIGITIZE MEDIA?

1.5 COMPUTER SCIENCE FOR EVERYONE

Chapter Learning Objectives


• To explain what computer science is about and what computer scientists are
concerned with.
• To explain why we digitize media.
• To explain why it’s valuable to study computing.
• To explain the concept of an encoding.
• To explain the basic components of a computer.

1.1 WHAT IS COMPUTER SCIENCE ABOUT?


Computer science is the study of process: how we or computers do things, how we
specify what we do, and how we specify what the stuff is that we’re processing. That’s
a pretty dry definition. Let’s try a metaphorical one.

Computer Science Idea: Computer Science Is the Study of Recipes


‘‘Recipes’’ here are a special kind—one that can be executed by a computational device,
but this point is only of importance to computer scientists. The important point overall is
that a computer science recipe defines exactly what has to be done.
More formally, computer scientists study algorithms which are step-by-step proce-
dures to accomplish a task. Each step in an algorithm is something that a computer
already knows how to do (e.g., add two small integer numbers) or can be taught how to
do (e.g., adding larger numbers including those with a decimal point). A recipe that can
run on a computer is called a program. A program is a way to communicate an algorithm
in a representation that a computer can execute.


To use our metaphor a bit more—think of an algorithm as the step-by-step way that
your grandmother made her secret recipe. She always did it the same way, and had a
28 Chapter 1 Introduction to Computer Science and Media Computation

reliably great result. Writing it down so that you can read it and do it later is like turning
her algorithm into a program for you. You execute the recipe by doing it—following
the recipe step-by-step in order to create something the way that your grandmother did.
If you give the recipe to someone else who can read the language of the recipe (maybe
English or French), then you have communicated that process to that other person, and
the other person can similarly execute the recipe to make something the way that your
grandmother did.
If you’re a biologist who wants to describe how migration works or how DNA
replicates, then being able to write a recipe that specifies exactly what happens, in
terms that can be completely defined and understood, is very useful. The same is true
if you’re a chemist who wants to explain how equilibrium is reached in a reaction.
A factory manager can define a machine-and-belt layout and even test how it works—
before physically moving heavy things into position—using computer programs. Being
able to exactly define tasks and/or simulate events is a major reason why computers
have radically changed so much of how science is done and understood.
In fact, if you can’t write a recipe for some process, maybe you don’t really under-
stand the process, or maybe the process can’t actually work the way that you are thinking
about it. Sometimes, trying to write the recipe is a test in itself. Now, sometimes you
can’t write the recipe because the process is one of the few that cannot be executed by
a computer. We will talk more about those in Chapter 14.
It may sound funny to call programs a recipe, but the analogy goes a long way. Much
of what computer scientists study can be defined in terms of recipes.
• Some computer scientists study how recipes are written: Are there better or worse
ways of doing something? If you’ve ever had to separate egg whites from yolks, you
realize that knowing the right way to do it makes a world of difference. Computer
science theoreticians think about the fastest and shortest recipes, and the ones that
take up the least amount of space (you can think about it as counter space—the
analogy works), or even use the least amount of energy (which is important when
running on low-power devices like cell phones). How a recipe works, completely
apart from how it’s written (e.g., in a program), is called the study of algorithms.
Software engineers think about how large groups can put together recipes that still
work. (Some programs, like the ones that keep track of credit card transactions,
have literally millions of steps!) The term software means a collection of computer
programs (recipes) that accomplish a task.
• Other computer scientists study the units used in recipes. Does it matter whether
a recipe uses metric or English measurements? The recipe may work in either
case, but if you don’t know what a pound or a cup is, the recipe is a lot less
understandable to you. There are also units that make sense for some tasks and
not others, but if you can fit the units to the tasks, you can explain yourself more
easily and get things done faster—and avoid errors. Ever wonder why ships at
sea measure their speed in knots? Why not use something like meters per second?
Sometimes, in certain special situations—on a ship at sea, for instance—the more
common terms aren’t appropriate or don’t work as well. Or we may invent new
kinds of units, like a unit that represents a whole other program or a computer, or
Exploring the Variety of Random
Documents with Different Content
the relieving force, 179, 187
Martin, Dr. A. W. P., Director of Imperial University in Peking, 23;
and the fire at the Legations, 68
Melotte, Chevalier de, his gallant defence, 56;
arrival of the relief force, 175, 177
Merghelynckem, M., First Secretary of Belgian Legation, 56;
saves the life of the French commanding officer, 117
Methodist Mission, burning of, 57
Mills, Colonel, General Chaffee’s Chief of Staff, 196
Missions:
arming of, 34, 35;
removal into the Legations, 49, 51;
work of Protestant and Roman Catholic missionaries, 57;
burning of Methodist, 57
Morrison, Dr., Times’ correspondent:
his kindness, 9;
stoned by rioters, 14;
his advice to the Legation Ministers, 44;
his hard work and cheerfulness, 69;
and the Chinese Christians at the Fu, 75;
wounded, 126
Myers, Captain, commander of the American marines in Peking, 17,
18, 21;
makes successful sorties, 25, 99, 100;
his hardships, 33;
saves the Dutch Legation, 57;
wounded, 103, 186

Nan-t’ang, burning of the, 131


Narahara, death of, 142
Neih, Chinese General, defeat and suicide of, 141
Norregarde, a Swedish missionary, becomes insane, 131
Norris, Rev., English chaplain at Peking:
the funeral of Oliphant, 105;
works hard on the fortifications, 118;
holds thanksgiving service, 203

Oliphant, funeral of, 105

Pei-t’ang, the Roman Catholic fortress cathedral, 36, 37;


relief of, 194
Peking—see also Legations:
Boxer rising, 7 et seq.;
burning of Feng-tai, 8;
positions of the Legations, 12;
telegraph broken, 21;
assassination of the Japanese Chancellor, 22;
burning of the missions, etc., 24 et seq.;
fires in, 25 et seq.;
description of, 26;
treachery of the Imperial Chinese troops, 45, 47;
burning of the Belgian Legation, 56;
burning of the Hanlin Library, 71;
entry of the relief force, 173 et seq.;
looting, 192
Pethick, William, Li Hung Chang’s private secretary, 11;
his opinion of the state of China, 19, 20;
his advice on the Yamen communication, 132;
and the antique China episode, 165
Pichon, M., the French Minister in Peking, 43, 78, 87, 120;
the Legion of Honour, 139
Poole, Dr., surgeon to the British Legation, 50, 52, 53, 59;
the Legation fire, 68
Porcelain, antique, 14
Rahden, Baron von, commander of Russian Legation force, 25, 30,
96;
and his undrilled soldiers, 110;
the defences of the Legations, 152;
the forbidden city, 200
Reilly, Captain, death of, 184
Roman Catholics in Peking, 36, 114
Rostand, Von, Austrian Chargé d’Affaires, 117;
and Sir Claude Macdonald, 121
Russian Legation. See Legations

Salvago Raggi, Marquis, 43, 86, 120


Seymour, Admiral, 44, 51
Shiba, Colonel, Japanese commander at Peking:
a sortie, 75;
description of, 95, 148
Shimonoseki, Treaty of, 163
Squiers, Herbert, Secretary of the American Legation, 6;
en route for Peking, 10;
his collection of antique porcelains, 14;
his hospitality, 15, 49, 73;
beginning of the siege, 22;
sends communication to Tien-tsin, 28, 29, 34;
removal to the British Legation, 53;
renovates an old cannon, 115;
becomes Sir Claude Macdonald’s chief of staff, 134;
communications with the Yamen, 136;
the defences of the Legations, 152;
leads a sortie, 179;
Sir Claude Macdonald’s opinion of, 186
Squiers, Fargo, his brave adventure, 58;
and the Legation fire, 68
Strouts, Captain, commander of the British marines in Peking, 18;
a sortie, 25;
Legation fire, 30;
mortally wounded, 125
Su, Prince, 98

Taku Forts, taking of, 49


Tien-tsin, first relief force sent to
Peking from, 15;
message received by besieged from, 140;
the capture of, 141, 158
Tsung-li Yamen, the Chinese Foreign Office, send a guard to protect
the temple of Linqua Su, 6;
Swedish missionary’s interview with, 131;
communicates with the Legations, 136 et seq., 145, 159, 166, 169;
send in food, 139
Tung Fu-hsiang, 51, 92
“Tungchou,” the Roman Catholic church, burning of, 24

Velde, Dr., German surgeon at Peking, the excellence of his work,


73, 109, 113, 143

Waller, Colonel, 177, 196


Warren, Mr., mortally wounded, 124
Water Gate, entry of Sikhs through the, 174

THE END
BILLING AND SONS, LTD., PRINTERS, GUILDFORD
Transcriber’s Notes:
New original cover art included with this eBook
is granted to the public domain.
Missing or obscured punctuation was silently
corrected.
Typographical errors were silently corrected.
Inconsistent spelling and hyphenation were
made consistent only when a predominant form
was found in this book.
*** END OF THE PROJECT GUTENBERG EBOOK BEHIND THE
SCENES IN PEKING ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree to
abide by all the terms of this agreement, you must cease using
and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it
away or re-use it under the terms of the Project Gutenberg
License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country where
you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
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!

textbookfull.com

You might also like