100% found this document useful (5 votes)
25 views54 pages

Introduction To Computing and Programming in Python, Global Edition Mark J. Guzdial Full Access

The document is an overview of 'Introduction to Computing and Programming in Python, Global Edition' by Mark J. Guzdial, which serves as an educational resource for learning programming concepts using Python. It includes various formats such as PDF eBook and study guides, and covers topics ranging from basic programming to multimedia applications. The book is praised for its comprehensive approach and is highly rated by users.

Uploaded by

ingerch1217
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 (5 votes)
25 views54 pages

Introduction To Computing and Programming in Python, Global Edition Mark J. Guzdial Full Access

The document is an overview of 'Introduction to Computing and Programming in Python, Global Edition' by Mark J. Guzdial, which serves as an educational resource for learning programming concepts using Python. It includes various formats such as PDF eBook and study guides, and covers topics ranging from basic programming to multimedia applications. The book is praised for its comprehensive approach and is highly rated by users.

Uploaded by

ingerch1217
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/ 54

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/

★★★★★ 4.8/5.0 (1696 reviews) ✓ 294 downloads Fan Favorites


"Perfect study material, highly recommended!" - John D.

textbookfull.com

PDF Available Immediately

EDUCATIONAL MATERIALS · STUDY SUPPLEMENTS · TESTING RESOURCES


Introduction to Computing and Programming in Python, Global
Edition Mark J. Guzdial

TEXTBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 ACADEMIC EDITION – LIMITED RELEASE

Available Instantly Access Library


Top Picks

A Concise Introduction to Programming in Python Second


Edition Mark J. Johnson
Buy now: https://textbookfull.com/product/a-concise-introduction-to
-programming-in-python-second-edition-mark-j-johnson/

Introduction to Scientific Programming with Python Joakim


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

Bite Size Python An Introduction to Python Programming 1st


Edition April Speight
Buy now: https://textbookfull.com/product/bite-size-python-an-intro
duction-to-python-programming-1st-edition-april-speight/

Introduction To Computing And Problem Solving Using Python


1st Edition E. Balaguruswamy
Buy now: https://textbookfull.com/product/introduction-to-computin
g-and-problem-solving-using-python-1st-edition-e-balaguruswamy/
Introduction to Computation and Programming Using Python
3rd Edition John V. Guttag
Buy now: https://textbookfull.com/product/introduction-to-computati
on-and-programming-using-python-3rd-edition-john-v-guttag/

Introduction to Computation and Programming Using Python


3rd Edition John V. Guttag
Buy now: https://textbookfull.com/product/introduction-to-computati
on-and-programming-using-python-3rd-edition-john-v-guttag-2/

Python Programming An Introduction to Computer Science


John M. Zelle
Buy now: https://textbookfull.com/product/python-programming-an-
introduction-to-computer-science-john-m-zelle/

How to Design Programs An Introduction to Programming and


Computing Matthias Felleisen
Buy now: https://textbookfull.com/product/how-to-design-programs
-an-introduction-to-programming-and-computing-matthias-felleisen/

Introduction to Computation and Programming Using Python


with Application to Understanding Data Guttag
Buy now: https://textbookfull.com/product/introduction-to-computati
on-and-programming-using-python-with-application-to-understandin
g-data-guttag/
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.

Another Random Document on
Scribd Without Any Related Topics
4lS KAYASTH part (/•) The Karan subcaste belong to Bihar,
and have two local divisions, the Gayawale from Gaya, and the
Tirhutia from Tirhut. (/) The Gaur Kayasths, like the Gaur Brahmans
and Rajputs, apparently take their name from Gaur or Lakhnauti, the
old kingdom of Bengal. They have the Khare and Dusre subdivisions,
and also three local groups named after Bengal, Delhi and Budaun.
(;//) The Nigum subcaste, whose name is apparently the same as
that of the Nikumbh Rajputs, are divided into two endogamous
groups, the Kadlm or old, and the Unaya, or those coming from
Unao. Sometimes the Unaya are considered as a separate thirteenth
subcaste of mixed descent. 3. Exo- Educated Kayasths now follow
the standard rule of gam7" exogamy, which prohibits marriage
between persons within five degrees of affinity on the female side
and seven on the male. That is, persons having a common
grandparent on the female side cannot intermarry, while for those
related through males the prohibition extends a generation further
back. This is believed to be the meaning of the rule but it is not
quite clear. In Damoh the Srivastab Kayasths still retain exogamous
sections which are all named after places in the United Provinces, as
Hamlrpur ki baink (section), Lucknowbar, Kashi ki Pande (a wise man
of Benares), Partabpuria, Cawnpore-bar, Sultanpuria and so on. They
say that the ancestors of these sections were families who came
from the above places in northern India, and settled in Damoh ;
here they came to be known by the places from which they had
immigrated, and so founded new exogamous sections. A man cannot
marry in his own section, or that of his mother or grandmother. In
the Central Provinces a man may marry two sisters, but in northern
India this is prohibited. 9. Mar- Marriage may be infant or adult, and,
as in many places husbands are difficult to find, girls occasionally
remain unmarried till nearly twenty, and may also be mated to boys
younger than themselves. In northern India a substantial
bridegroom-price is paid, which increases for a well-educated boy,
but this custom is not so well established in the Central
ii MARRIAGE SONGS 419 Provinces. However, in Damoh it
is said that a sum of Rs. 200 is paid to the bridegroom's family. The
marriage ceremony is performed according to the proper ritual for
the highest or Brahma form of marriage recognised by Manu with
Vedic texts. When the bridegroom arrives at the bride's house he is
given sherbet to drink. It is said that he then stands on a pestle, and
the bride's mother throws wheat-flour balls to the four points of the
compass, and shows the bridegroom a miniature plough, a grinding
pestle, a churning-staff and an arrow, and pulls his nose. The
bridegroom's struggles to prevent his mother-in-law pulling his nose
are the cause of much merriment, while the two parties afterwards
have a fight for the footstool on which he stands.1 An image of a
cow in flour is then brought, and the bridegroom pierces its nostrils
with a little stick of gold. Kayasths do not pierce the nostrils of
bullocks themselves, but these rites perhaps recall their dependence
on agriculture in their capacity of village accountants. After the
wedding the bridegroom's father takes various kinds of fruit, as
almonds, dates and raisins, and fills the bride's lap with them four
times, finally adding a cocoanut and a rupee. This is a ceremony to
induce fertility, and the cocoanut perhaps represents a child. The
following are some specimens of songs sung at 10. Marweddings.
The first is about Rama's departure from Aiodhia nage 0 r j songs.
when he went to the forests : Now Hari (Rama) has driven his
chariot forth to the jungle. His father and mother are weeping.
Kaushilya 2 stood up and said, ' Now, whom shall I call my diamond
and my ruby ? ' Dasrath went to the tower of his palace to see his
son ; As Rama's chariot set forth under the shade of the trees, he
wished that he might die. Bharat ran after his brother with naked
feet. He said, ' Oh brother, you are going to the forest, to whom do
you give the kingdom of Oudh ? ' Rama said, ' When fourteen years
have passed away I shall come back from the jungles. Till then I
give the kingdom to you.' The following is a love dialogue : 1 Hindus
of Gujarat, p. 72. 2 Dasrath and Kaushilya were the father and
mother of Rama.
420 KAYASTH part Make a beautiful garden for me to see
my king. In that garden what flowers shall I set? Lemons, oranges,
pomegranates, figs. In that garden what music shall there be ? A
tambourine, a fiddle, a guitar and a dancing girl. In that garden
what attendants shall there be ? A writer, a supervisor, a secretary
for writing letters.1 The next is a love-song by a woman : How has
your countenance changed, my lord ? Why speak you not to your
slave ? If I were a deer in the forest and you a famous warrior,
would you not shoot me with your gun ? If I were a fish in the water
and you the son of a fisherman, would you not catch me with your
drag-net ? If I were a cuckoo in the garden and you the gardener's
son, would you not trap me with your liming-stick ? The last is a
dialogue between Radha and Krishna. Radha with her maidens was
bathing in the river when Krishna stole all their clothes and climbed
up a tree with them. Girdhari is a name of Krishna : R. You and I
cannot be friends, Girdhari ; I am wearing a silkembroidered cloth
and you a black blanket. You are the son of old Nand, the shepherd,
and I am a princess of Mathura. You have taken my clothes and
climbed up a kadamb tree. I am naked in the river. K. I will not give
you your clothes till you come out of the water. R. If I come out of
the water the people will laugh and clap at me. All my companions
seeing your beauty say, ' You have vanquished us ; we are
overcome.' ii. Social Polygamy is permitted but is seldom resorted to,
except for the sake of offspring. Neither widow- marriage nor
divorce are recognised, and either a girl or married woman is
expelled from the caste if detected in a liaison. A man may keep a
woman of another caste if he does not eat from her hand nor permit
her to eat in the chauk or purified place where he and his family
take their meals. The practice of keeping women was formerly
common but has now been largely suppressed. Women of all castes
were kept except Brahmans and Kayasths. Illegitimate children were
known as Dogle or Sura.it and called Kayasths, ranking as 1 These
are the occupations of the Kayasths.
n RELIGION- SOCIAL CUSTOMS 421 an inferior group of
the caste. And it is not unlikely that in the past the descendants of
such irregular unions have been admitted to the Dusre or lower
branch of the different subcastes. During the seventh month of a
woman's pregnancy a 12. Birth dinner is given to the caste-fellows
and songs are sung. custonisAfter this occasion the woman must not
go outside her own village, nor can she go to draw water from a well
or to bathe in a tank. She can only go into the street or to another
house in her own village. On the sixth day after a birth a dinner is
given to the caste and songs are sung. The women bring small silver
coins or rupees and place them in the mother's lap. The occasion of
the first appearance of the signs of maturity in a girl is not observed
at all if she is in her father's house. But if she has gone to her
father-in-law's house, she is dressed in new clothes, her hair after
being washed is tied up, and she is seated in the cliaiik or purified
space, while the women come and sing songs. The Kayasths
venerate the ordinary Hindu deities. 13. ReiiThey worship
Chitragupta, their divine ancestor, at weddings glon' and at the Holi
and Diwali festivals. Twice a year they venerate the pen and ink, the
implements of their profession, to which they owe their great
success. The patwaris in Hoshangabad formerly received small fees,
known as dizvat pfija, from the cultivators for worshipping the ink-
bottle on their behalf, presumably owing to the idea that, if
neglected, it might make a malicious mistake in the record of their
rights. The dead are burnt, and the proper offerings are made 14.
Social on the anniversaries, according to the prescribed Hindu
customsritual. Kayasth names usually end in Prasad, Singh, Baksh,
Sewak, and Lala in the Central Provinces. Lala, which is a term of
endearment, is often employed as a synonym for the caste. Dada or
uncle is a respectful term of address for Kayasths. Two names are
usually given to a boy, one for ceremonial and the other for ordinary
use. The Kayasths will take food cooked with water from Brahmans,
and that cooked without water (pakki) from Rajputs and Banias.
Some Hindustani Brahmans, as well
422 KEWAT 15. Occupation. as Khatris and certain classes
of Banias, will take pakki food from Kayasths. Kayasths of different
subcastes will sometimes also take it from each other. They will give
the huqqa with the reed in to members of their own subcaste, and
without the reed to any Kayasth. The caste eat the flesh of goats,
sheep, fish, and birds. They were formerly somewhat notorious for
drinking freely, but a great reform has been effected in this respect
by the community itself through the agency of their caste
conference, and many are now total abstainers. The occupations of
the Kayasths have been treated in discussing the origin of the caste.
They set the greatest store by their profession of writing and say
that the son of a Kayasth should be either literate or dead. The
following is the definition of a Lekhak or writer, a term said to be
used for the Kayasths in Puranic literature : " In all courts of justice
he who is acquainted with the languages of all countries and
conversant with all the Shastras, who can arrange his letters in
writing in even and parallel lines, who is possessed of presence of
mind, who knows the art of how and what to speak in order to carry
out an object in view, who is well versed in all the Shastras, who can
express much thought in short and pithy sentences, who is apt to
understand the mind of one when one begins to speak, who knows
the different divisions of countries and of time,1 who is not a slave
to his passions, and who is faithful to the king deserves the name
and rank of a Lekhak or writer." 2 1. General notice. Kewat, Khewat,
Kaibartta.3— A caste of fishermen, boatmen, grain-parchers, and
cultivators, chiefly found in the Chhattlsgarh Districts of Drug,
Raipur, and Bilaspur. They numbered 170,000 persons in 191 1. The
Kewats or Kaibarttas, as they are called in Bengal, are the modern
representatives of the Kaivartas, a caste mentioned in Hindu classical
literature. Sir H. Risley explains the 1 Geography and Astronomy. Mr.
Mahfuz Ali, tahslldar, Rajnand2 Quoted from the Matsapuran in a
£aon' Mr. Jowahir Singh, Settlement criticism by Babu Krishna Nag
Verma. Superintendent, Sambalpur, and Mr. Aduram Chaudhri of the
Gazetteer 3 This article is based on papers by Office.
ii GENERAL NOTICE 423 origin of the name as follows : l "
Concerning the origin of the name Kaibartta there has been
considerable difference of opinion. Some derive it from ka, water,
and vartta, livelihood ; but Lassen says that the use of ka in this
sense is extremely unusual in early Sanskrit, and that the true
derivation is Kivarta, a corruption of Kimvarta, meaning a person
following a low or degrading occupation. This, he adds, would be in
keeping with the pedigree assigned to the caste in Manu, where the
Kaivarta, also known as Margava or Dasa, is said to have been
begotten by a Nishada father and an Ayogavi mother, and to subsist
by his labour in boats. On the other hand, the Brahma- Vaivarta
Purana gives the Kaibartta a Kshatriya father and a Vaishya mother,
a far more distinguished parentage ; for the Ayogavi having been
born from a Sudra father and a Vaishya mother is classed as
pratiloma, begotten against the hair, or in the inverse order of the
precedence of the castes." The Kewats are a mixed caste. Mr. Crooke
says that they merge on one side into the Mallahs and on the other
into the Binds. In the Central Provinces their two principal
subdivisions are the Laria and Uriya, or the residents of the
Chhattisgarh and Sambalpur plains respectively. The Larias are
further split up into the Larias proper, the Kosbonwas, who grow
kosa or tasar silk cocoons, and the Binjhwars and Dhuris (grain-
parchers). The Binjhwars are a Hinduised group of the Baiga tribe,
and in Bhandara they have become a separate Hindu caste,
dropping the first letter of the name, and being known as Injhwar.
The Binjhwar Kewats are a group of the same nature. The Dhuris
are grain-parchers, and there is a separate Dhuri caste ; but as
grain-parching is also a traditional occupation of the Kewats, the
Dhuris may be an offshoot from them. The Kewats are so closely
connected with the Dhlmars that it is difficult to make any distinction
; in Chhattisgarh it is said that the Dhlmars will not act as ferrymen,
while the Kewats will not grow or sell singara or water -nut. The
Dhlmars worship their fishingnets on the Akti day, which the Kewats
will not do. Both the Kewats and Dhlmars are almost certainly
derived from the primitive tribes. The Kewats say that formerly the 1
Tribes and Castes of Bengal, art. Kaibartta.
424 KEWAT PART Hindus would not take water from them ;
but on one occasion during his exile Rama came to them and asked
them to ferry him across a river ; before doing so they washed his
feet and drank the water, and since that time the Hindus have
considered them pure and take water from their hands. This story
has no doubt been invented to explain the fact that Brahmans will
take water from the non-Aryan Kewats, the custom having in reality
been adopted as a convenience on account of their employment as
palanquin-bearers and indoor servants. But in Saugor, where they
are not employed as servants, and also grow san-hemp, their
position is distinctly lower and no high caste will take water from
them. The caste have also a number of exogamous groups,
generally named after plants or animals, or bearing some id mar-
nickname given to the reputed founder. Instances of the first class
are Tuma, a gourd, Karsayal, a deer, Bhalwa, a bear, Ghughu, an
owl, and so on. Members of such a sept abstain from injuring the
animal after which the sept is named or eating its flesh ; those of
the Tuma sept worship a gourd with offerings of milk and a cocoanut
at the Holi festival. Instances of titular names are Garhtod, one who
destroyed a fort, Jhagarha quarrelsome, Dehri priest, Kala black, and
so on. One sept is named Rawat, its founder having probably
belonged to the grazier caste. Members of this sept must not visit
the temple of Mahadeo at Rajim during the annual fair, but give no
explanation of the prohibition. Others are the Ahira, also from the
Ahlr (herdsman) caste ; the Rautele, which is the name of a
subdivision of Kols and other tribes ; and the Sonwani or ' gold water
' sept, which is often found among the primitive tribes. In some
localities these three have now developed into separate subcastes,
marrying among themselves ; and if any of their members become
Kablrpanthis, the others refuse to eat and intermarry with them. The
marriage of members of the same sept is prohibited, and also the
union of first cousins. Girls are generally married under ten years of
age, but if a suitable husband cannot be found for a daughter, the
parents will make her over to any member of the caste who offers
himself on condition that he bears the expenses of the
ii SOCIAL CUSTOMS 425 marriage. In Sambalpur she is
married to a flower. Sir H. Risley notes 1 the curious fact that in
Bihar it is deemed less material that the bridegroom should be older
than the bride than that he should be taller. " This point is of the first
importance, and is ascertained by actual measurement. If the boy is
shorter than the girl, or if his height is exactly the same as hers, it is
believed that the union of the two would bring ill-luck, and the
match is at once broken off." The marriage is celebrated in the
customary manner by walking round the sacred pole, after which the
bridegroom marks the forehead of the bride seven times with
vermilion, parts her hair with a comb, and then draws her cloth over
her head. The last act signifies that the bride has become a married
woman, as a girl never covers her head. In Bengal a drop of blood is
drawn from the fingers of the bride and bridegroom and mixed with
rice, and each eats the rice containing the blood of the other. The
anointing with vermilion is probably a substitute for this. Widow-
remarriage and divorce are permitted. In Sambalpur a girl who is left
a widow under ten years of age is remarried with full rites as a
virgin. The Kewats worship the ordinary Hindu deities and 3- Social
believe that a special goddess, Chaurasi Devi, dwells in their boats
and keeps them from sinking. She is propitiated at the beginning of
the rains and in times of flood, and an image of her is painted on
their boats. They bury the dead, laying the corpse with the feet to
the south, while some clothes, cotton, til and salt are placed in the
grave, apparently as a provision for the dead man's soul. They
worship their ancestors at intervals on a Monday or a Saturday with
an offering of a fowl. As is usual in Chhattlsgarh, their rules as to
food are very lax, and they will eat both fowls and pork.
Nevertheless Brahmans will take water at their hands and eat the
rice and gram which they have parched. The caste consider fishing
to have been their original occupation, and tell a story to the effect
that their ancestors saved the deity in their boat on the occasion of
the Deluge, and in return were given the power of catching three or
four times 1 Tribes and Castes of Bengal, art. Kewat. 2 Tribes and
Castes of Bengal, ibidem. customs.
426 KEIVAT part ii as mail}- fish as ordinary persons in the
same space of time. Some of them parch gram and rice, and others
act as coolies and banghy '-bearers.* Kewats are usually in poor
circumstances, but they boast that the town of Bilaspur is named
after Bilasa Keotin, a woman of their caste. She was married, but
was sought after by the king of the country, so she held out her
cloth to the sun, calling on him to set it on fire, and was burnt alive,
preserving her virtue. Her husband burnt himself with her, and the
pair ascended to heaven. 1 A curved stick carried across the
shoulders, from which are suspended two panniers.
KHAIRWAR [Authorities : Colonel Dalton's Ethnology of
Bengal ; Sir H. Risley's Tribes and Castes of Bengal ; Mr. Crooke's
Tribes and Castes of the N.-M'.l'. and OudA.] LIST OF PARAGRAPHS
I. Historical notice of the tribe. 5Marriage. 2. Its origin. 6. Disposal of
the dead. :>■ Tribal subdivisions. 7Religion. 4Exogamous septs. 8.
Inheritance. 9. The KJiairwas of Dam oh. Khairwar, Kharwar, Khaira,
Khairwa.1 — A primitive 1. Historitribe of the Chota Nagpur plateau
and Bihar. Nearly 20,000 ofthe Khairwars are now under the
jurisdiction of the Central tribe. Provinces, of whom two-thirds
belong to the recently acquired Sarguja State, and the remainder to
the adjoining States and the Bilaspur District. A few hundred
Khairvvars or Khairwas are also returned from the Damoh District in
the Bundelkhand country. Colonel Dalton considers the Khairwars to
be closely connected with the Cheros. He relates that the Cheros,
once dominant in Gorakhpur and Sha.ha.bad, were expelled from
these tracts many centuries ago by the Gorkhas and other tribes,
and came into Palamau. " It is said that the Palamau population then
consisted of Kharwars, Gonds, Mars, Korwas, Parheyas and Kisans.
Of these the Kharwars were the people of most consideration. The
Cheros conciliated them and allowed them to remain in peaceful
possession of the hill tracts bordering on Sarguja ; all the Cheros of
note who assisted in the expedition obtained military service grants
of land, which they still retain. It is 1 This article is based on Mr. and
some notes taken by Mr. I lira Lai Crooke's and Colonel Dalton's
accounts, at Raigarh . 427
428 KHAIRWAR part popularly asserted that at the
commencement of the Chero rule in Palamau they numbered twelve
thousand families and the Kharwars eighteen thousand, and if an
individual of one or the other is asked to what tribe he belongs, he
will say not that he is a Chero or a Kharwar, but that he belongs to
the twelve thousand or the eighteen thousand, as the case may be.
Intermarriages between Chero and Kharwar families have taken
place. A relative of the Palamau Raja married a sister of Maninath
Singh, Raja of Ramgarh, and this is among themselves an admission
of identity of origin, as both claiming to be Rajputs they could not
intermarry till it was proved to the satisfaction of the family priest
that the parties belonged to the same class. . . . The Rajas of
Ramgarh and Jashpur are members of this tribe, who have nearly
succeeded in obliterating their Turanian traits by successive
intermarriages with Aryan families. The Jashpur Raja is wedded to a
lady of pure Rajput blood, and by liberal dowries has succeeded in
obtaining a similar union for three of his daughters. It is a costly
ambition, but there is no doubt that the liberal infusion of fresh
blood greatly improves the Kharwar physique." 1 This passage
demonstrates the existence of a close connection between the
Cheros and Khairwars. Elsewhere Colonel Dalton connects the
Santals with the Khairwars as follows : 2 "A wild goose coming from
the great ocean alighted at Ahiri Pipri and there laid two eggs. From
these two eggs a male and female were produced, who were the
parents of the Santal race. From Ahiri Pipri our (Santal) ancestors
migrated to Hara Dutti, and there they greatly increased and
multiplied and were called Kharwar." This also affords some reason
for supposing that the Khairwars are an offshoot of the Cheros and
Santals. Mr. Crooke remarks, "That in Mirzapur the people
themselves derive their name either from their occupation as makers
of catechu {/chair) or on account of their emigration from some
place called Khairagarh, regarding which there is a great difference
of opinion. If the Santal tradition is to be accepted, Khairagarh is the
place of that name in the Hazaribagh District ; but the Mlrzapur
tradition seems to point to some locality in the south or 1 Ethnology
of Bengal, pp. 128, 129. 2 mdevi, pp. 209, 210.
ii HISTORICAL NOTICE OF THE TRIBE 429 west, in which
case Khairagarh may be identified with the most important of the
Chhattlsgarh Feudatory States, or with the pargana of that name in
the Allahabad District." l According to their own traditions in Chota
Nagpur, Sir H. Risley states that,2 " The Kharwars declare their
original seat to have been the fort of Rohtas, so called as having
been the chosen abode of Rohitaswa, son of Harlschandra, of the
family of the Sun. From this ancient house they also claim descent,
calling themselves Surajvansis, and wearing the Janeo or caste
thread distinguishing the Rajputs. A less flattering tradition makes
them out to be the offspring of a marriage between a Kshatriya man
and a Bhar woman contracted in the days of King Ben, when
distinctions of caste were abolished and men might marry whom
they would." A somewhat similar story of themselves is told by the
tribe in the Bamra State. Here they say that their original ancestors
were the Sun and a daughter of Lakshmi,the goddess of wealth, who
lived in the town of Sara. She was very beautiful and the Sun
desired her, and began blowing into a conch-shell to express his
passion. While the girl was gaping at the sight and sound, a drop of
the spittle fell into her mouth and impregnated her. Subsequently a
son was born from her arm and a daughter from her thigh, who
were known as Bhujbalrai and Janghrai.3 Bhujbalrai was given great
strength by the Sun, and he fought with the people of the country,
and became king of Rathgarh. But in consequence of this he and his
family grew proud, and Lakshmi determined to test them whether
they were worthy of the riches she had given them. So she came in
the guise of a beggar to the door, but was driven away without alms.
On this she- cursed them, and said that their descendants, the
Khairwars, should always be poor, and should eke out a scanty
subsistence from the forests. And in consequence the Khairwars
have ever since been engaged in boiling wood for catechu. Mr. Hira
Lai identifies the Rathgarh of this story with the tract of Rath in the
north of the Raigarh 1 Tribes and Castes, art. Kharwar. the whole
story is obviously a Brah2 Tribes and Castes of Bengal. manical
legend. Balrai seems a cor3 From bhuj, an arm, andj'angk, a ruption
of Balariim, the brother of thigh. These are Hindi words, and
Krishna.
43o KHAIRWAR part State and the town of Sara, where
Lakshmi's daughter lived and her children were born, with Saria in
Sarangarh. On the information available as to the past history of the
tribe it seems probable that the Khairwars may, as su^csted by Sir
H. Risley, be an offshoot from some other group. The most probable
derivation of the name seems to be from the khair or catechu tree
{Acacia catechu) ; and it may be supposed that it was the adoption
as a calling of the making of catechu which led to their
differentiation. Mr. Crooke derives their name either from the khair
tree or a place called Khairagarh ; but this latter name almost
certainly means ' The fort of the khair trees.' The Khairwas or
Khairwars of the Kaimur hills, who are identified by Colonel Dalton
and in the India Census of 1901 with the Khairwars of Chota Nagpur,
are certainly named after the tree ; they are generally recognised as
being Gonds who have taken to the business of boiling catechu, and
are hence distinguished, being a little looked down upon by other
Gonds. Mr. Crooke describes them in Mlrzapur as " Admittedly a
compound of various jungle tribes who have taken to this special
occupation ; while according to another account they are the
offspring of the Saharias or Saonrs, with whom their sept names are
said to be identical." He also identifies them with the Kathkaris of
Bombay, whose name means ' makers of hatha or prepared
catechu.' The Khairwars of Chota Nagpur have everywhere a
subdivision which makes catechu, this being known as Khairchura in
the Central Provinces, Khairi in Bengal and Khairaha in the United
Provinces. This group is looked down upon by the other Khairwars,
who consider their occupation to be disreputable and do not marry
with them. Possibly the preparation of catechu, like basket- and mat-
making, is despised as being a profession practised by primitive
dwellers in forests, and so those Khairwars who have become more
civilised are now anxious to disclaim it. Sir H. Risley has several
times pointed out the indeterminate nature of the constitution of the
Chota Nagpur tribes, between several of whom intermarriage is
common. And it seems certain that the tribes as we know them now
must have been differentiated from one or more common stocks
much in the same fashion
ii TRIBAL SUBDIVISIONS 431 as castes, though rather by
the influence of local settlement than by differences of occupation,
and at a much earlier date. And on the above facts it seems likely
that the Khairwars of Chota Nagpur are an occupational offshoot of
the Cheros and Santals, as those of the Kaimur hills are of the Gonds
and Savars. Colonel Dalton states that the tribe had four
subdivisions, 3. Tribal Bhogta, Mahto, Ravvat and Manjhi. Of these
Mahto simply ^ions. means a village headman, and is used as a title
by many castes and tribes ; Rawat is a term meaning chief, and is in
common use as a title ; and Manjhi too is a title, being specially
applied to boatmen, and also means a village headman among the
Santals. These divisions, too, afford some reason for considering the
tribe to be a mixed group. Other occupational subtribes are recorded
by Sir H. Risley, and are found in the Central Provinces, but these
apparently have grown up since Colonel Dalton's time. The most
important group in Bengal are the Bhogtas, who are found, says
Colonel Dalton, " In the hills of Palamau, skirting Sarguja, in Tori and
Bhanwar Pahar of Chota Nagpur and other places. They have always
had an indifferent reputation. The head of the clan in Palamau was a
notorious freebooter, who, after having been outlawed and
successfully evaded every attempt to capture him, obtained a.jagir 1
on his surrendering and promising to keep the peace. He kept to his
engagement and died in fair repute, but his two sons could not resist
the opportunity afforded by the disturbances of 1857-58. After
giving much trouble they were captured ; one was hanged, the other
transported for life and the estate was confiscated." Mr. Crooke
notes that the Khairwars since adopting Hinduism performed human
sacrifices to Kali. Some of our people who fell into their hands during
the Mutiny were so dealt with." In the Central Provinces there is a
group known as Surajvansi or Descendants of the Sun, or
Janeodhari, ' Those who wear the sacred thread.' This is the
aristocratic division of the caste, to which the chiefs and zamlndars
belong, and according to the usual practice they have consolidated
their 1 Estate held on feudal tenure. 2 Religion and Folklore of
Northern India, vol. ii. p. 170.
433 K HAIR WAR part higher position by marrying only
among themselves. Other groups are the Dualbandhi, who say that
they are so called because they make a livelihood by building the
earthen diwdls or walls for houses and yards ; but in Mlrzapur they
derive the name from dual, a leather belt which is supposed to have
been the uniform of their forefathers when serving as soldiers.1 The
Ffitbandhi or silk-makers, according to their own story, are thus
named because their ancestors were once very rich and wore silk ;
but a more probable hypothesis is that they were rearers of tasar
silk cocoons. The Beldar or Matkora work as navvies, and are also
known as Kawarvansi or ' Descendants of the Kawars,' another tribe
of the locality ; and last come the Khairchura, who take their name
from the khair tree and are catechu-makers. 4. Exo- The tribe have a
large number of exogamous groups ;p.mous named after plants and
animals. Members of the mouse, septs. tortoise, parrot, pig, monkey,
vulture, banyan tree and datepalm septs worship their totem animal
or tree, and when they find the dead body of the animal they throw
away an earthen cooking-pot to purify themselves, as is done when
a member of the family dies. Those of the Dhan (rice), Non (salt),
Dila (plough) and Dhenki (rice pounding-lever) septs cannot
dispense with the use of these objects, but make a preliminary
obeisance before employing them. Those of the Kami sept sprinkle
water mixed with kans 2 grass over the bride and bridegroom at the
marriage ceremony, and those of the Chandan or sandalwood sept
apply sandal -paste to their foreheads. They cannot clearly explain
the meaning of these observances, but some of them have a vague
idea that they are descended from the totem object. Marriage is
either infant or adult, and in the latter case a girl is not disposed of
without her consent. A bride-price varying from five to ten rupees is
paid, and in the case of a girl given to a widower the amount is
doubled. The Hindu ceremonial has been adopted for the wedding,
and an auspicious day is fixed by a Brahman. In Bengal Sir H. Risley
notes that " Remnants of non-Aryan usage may be discerned in the
marriage ceremony itself. Both parties must first go through the
form of marriage to a mango tree or at least a branch of 1 Crookc,
Tribes and Castes. 2 Saccharum spontaneum. riage.
i: DISPOSAL OF THE DEAD 433 the tree ; and must
exchange blood mixed with sindur, though in the final and binding
act sindur alone is smeared by the bridegroom upon the bride's
forehead and the parting of her hair." As has been pointed out by Mr.
Crooke, the custom of smearing vermilion on the bride's forehead is
a substitute for an earlier anointing with blood ; just as the original
idea underlying the offering of a cocoanut was that of substitution
for a human head. In some cases blood alone is still used. Thus Sir
H. Risley notes that among the Birhors the marriage rite is
performed by drawing blood from the little fingers of the bride and
bridegroom and smearing it on each of them.1 The blood-covenant
by which a bride was admitted to her husband's sept by being
smeared with his blood is believed to have been a common rite
among primitive tribes. As a rule, the tribe bury the dead, though
the Hindu 6. Disposal custom of cremation is coming into fashion
among the well- dead to-do. Before the interment they carry the
corpse seven times round the grave, and it is buried with the feet
pointing to the north. They observe mourning for ten days and
abstain from animal food and liquor during that period. A curious
custom is reported from the Bilaspur District, where it is said that
children cut a small piece of flesh from the finger of a dead parent
and swallow it, considering this as a requital for the labour of the
mother in having carried the child for nine months in her womb. So
in return they carry a piece of her flesh in their bodies. But the
correct explanation as given by Sir J. G. Frazer is that they do it to
prevent themselves from being haunted by the ghosts of their
parents. " Thus Orestes,2 after he had gone mad from murdering his
mother, recovered his wits by biting off one of his own fingers ; since
his victim was his own mother it might be supposed that the tasting
of his own blood was the same as hers ; and the furies of his
murdered mother, which had appeared black to him before,
appeared white as soon as he had mutilated himself in this way. The
Indians of Guiana believe that an 1 Tribes and Castes, art. Birhor. all
of homicide, but it seems likely that the action of the Khairwars may
be 2 The above instances are repro- based on the same motives, as
the duced from Sir J. G. Frazer's Psyche's fear of ghosts is strong
among these Task (London, 1909). These cases are tribes. VOL. Ill 2
F
The text on this page is estimated to be only 19.77%
accurate

KHAIRWAR ■■■■ Inherit »d who has slain his man musl go


mad unless I blood of his victim, the notion apparently being thai Hi.
ivii drives him crazy. A similar custom was Maoris in battle. When a
warrior had slain his foi mbat, he tasted his blood, believing that this
from the avenging spirit [atud] of his victim; for tin • mi iiM'd thai
'the moment a slayer had tasted the in, the dead man became a part
of his being and [>lai cd In under the protei Hon of the atua or
guardianspiril ed.' Someofthe North American Indians also • blood ol
their enemies in battle. Strange as il in his trulj superstition exists
apparently in li is day. There is a widespread opinion in < '.il.'i
murderer is to es< ape he must suck his victim's I from the reeking
blade of the dagger with win', li Tin i .1 the tribe is of the usual
animistic type. Colonel i notes thai they have, like the Kols, a village
■ Pahan or Baiga. He is always one of the impui i Bhuiya, a Kharwar
or a Korwa, and he 1 nnial sacrifice of a buffalo in the sacred roi I.
near the village. The fact that the Khairwn members ol the Korwa
and Bhuiya lnl" ■ Uage priests may be taken to indicate that ,l"' l-lHi
• earliei residents of the country, and are on lln ■'" ■ ; by the
Khairwars as later arrivals for thc ' ' oi the indigenous deities. Colonel
Dalton states th.-i I KhairwSrs made no prayers to any of the lli,hl" !
when in greal trouble they appealed to the ••nn- '" ,1"- i ntral
Provinces the main body of the tribe, ;"'(1 I who belong to the
landholding class, profess tin- I 1 1 in religion. _ '"'■ Lrs have now
also ado- |hc Hindu rule of mheritain I,,,,. aban.loneiU^. M CUstom
which j4 mj^ M. "Here St SU" 1M J^'h Vofthc to tin- oj^l IHT^...^H
li,' dren. led to Wyowwzcv COD • it I •' Colo::. Dl re: • . 'ltai w'r. 'km
The text on this page is estimated to be only 26.46%
accurate

THE K HAIR WAS ^t a*. ' ■to ipq ^■^ opnwi »Kob. . icoftk
Com, audit t sacra brothers. Daughters can never inhei entitled to
live in the ancestral home till they are man .1." l The Khairwas or
Khairwars o\ the btimur hills are derived, as already seen, from the
Gond I Savars, and therefore are ethnologically a distinc from tho
the Chota Nagpur plateau, who have icribed above. But as nearly
every caste is made up of d ;c ethnol< elements held together by
the tie m occupation, it does not seem worth while to treat tl ips
separately. Colonel Dalton, who also identifies them \ the main tribe,
records an interesting notice of them at a pei iod : " There is in the
seventh volume of the ' tic Reseai a notice of the Kharwars of the
Kaimur hill i the Mlr/.apui District, to the north of the Son river, by I
in J. L\ Hlunt, who in his journey from Chunar to Ellora ii ..i>. i; ro. |,
mol with them and describes them as a very pi vc tribe. He visited
one of their villages consisting oi i do en pooi huts, and though
proceeding with the mosl caution, unattended, to prevent alarm, the
ii ats fled al his approach. The women were seen, as: by Lhe men,
carrying off their children and moving ipeed to hide themselves in
the woods. It was observe* h.it they were nearly naked, and the
only articles of dom use found in the deserted huts were a few
gourds foi Is some bows and arrows, and some fowls as wild their
masters With great difficulty, by the emploj m mediators, some of
the men were induced to They nearly naked, but armed with bows
and irrows and a hatchet." In Damoh the Khairwars are said to coic
from I'.uina State. During the working season they in temporary
sheds in the forest, and migrate from placi place as the supply of
trees is exhausted. Having cul i n .1 trc< they strip off the bark and
cut the inner and wood into small pieces, which are boiled for two or
thi days until a thick black paste is obtained. Froi tcr is all< to drain
off, and the residue is made ini in the sun. It is eaten in small pieces
v I leal and areca-nut. Duty is levied by the Forest D< rtmenl al the
1 Risley, loc. cit. - Ethnolc g Hunt Damoh.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

textbookfull.com

You might also like