100% found this document useful (2 votes)
86 views

Fundamentals Of Python First Programs MindTap Course List 3rd Edition Kenneth A. Lambert 2024 scribd download

The document provides information about various educational ebooks available for download on ebookgate.com, including titles like 'Fundamentals of Python: First Programs' and 'Writing Ten Core Concepts'. It also outlines the contents of the 'Fundamentals of Python' textbook, detailing chapters on software development, data types, loops, strings, and more. Additionally, it includes copyright information and notes on the availability of digital formats.

Uploaded by

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

Fundamentals Of Python First Programs MindTap Course List 3rd Edition Kenneth A. Lambert 2024 scribd download

The document provides information about various educational ebooks available for download on ebookgate.com, including titles like 'Fundamentals of Python: First Programs' and 'Writing Ten Core Concepts'. It also outlines the contents of the 'Fundamentals of Python' textbook, detailing chapters on software development, data types, loops, strings, and more. Additionally, it includes copyright information and notes on the availability of digital formats.

Uploaded by

nemoomonca
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/ 89

Get the full ebook with Bonus Features for a Better Reading Experience on ebookgate.

com

Fundamentals Of Python First Programs MindTap


Course List 3rd Edition Kenneth A. Lambert

https://ebookgate.com/product/fundamentals-of-python-first-
programs-mindtap-course-list-3rd-edition-kenneth-a-lambert/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookgate.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Writing Ten Core Concepts w MLA9E Updates MindTap Course


List 3rd Edition Robert P. Yagelski

https://ebookgate.com/product/writing-ten-core-concepts-w-
mla9e-updates-mindtap-course-list-3rd-edition-robert-p-yagelski/

ebookgate.com

Python Programming for Teens 1st Edition Kenneth A.


Lambert

https://ebookgate.com/product/python-programming-for-teens-1st-
edition-kenneth-a-lambert/

ebookgate.com

The Fundamentals of Drawing Portraits A Practical and


Inspirational Course Barrington Barber

https://ebookgate.com/product/the-fundamentals-of-drawing-portraits-a-
practical-and-inspirational-course-barrington-barber/

ebookgate.com

Physiology and nutrition for amateur wrestling First


Edition Lambert

https://ebookgate.com/product/physiology-and-nutrition-for-amateur-
wrestling-first-edition-lambert/

ebookgate.com
A First Course in Topology John Mccleary

https://ebookgate.com/product/a-first-course-in-topology-john-
mccleary/

ebookgate.com

Python Crash Course A Hands On Project Based Introduction


to Programming 1st Edition Eric Matthes

https://ebookgate.com/product/python-crash-course-a-hands-on-project-
based-introduction-to-programming-1st-edition-eric-matthes/

ebookgate.com

The History of Mathematics A Brief Course 3rd ed 2013 3rd


Edition Roger L. Cooke

https://ebookgate.com/product/the-history-of-mathematics-a-brief-
course-3rd-ed-2013-3rd-edition-roger-l-cooke/

ebookgate.com

Fundamentals of Geomorphology 3rd Edition Routledge


Fundamentals of Physical Geography Richard Huggett

https://ebookgate.com/product/fundamentals-of-geomorphology-3rd-
edition-routledge-fundamentals-of-physical-geography-richard-huggett/

ebookgate.com

A First Course in Loop Quantum Gravity Gambini

https://ebookgate.com/product/a-first-course-in-loop-quantum-gravity-
gambini/

ebookgate.com
Fundamentals
of Python First
Programs Third Edition

Kenneth A. Lambert
Fundamentals
of Python
First Programs
Third Edition

Kenneth A. Lambert

Australia • Brazil • Canada • Mexico • Singapore • United Kingdom • United States

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.

Important Notice: Media content referenced within the product description or the product
text may not be available in the eBook version.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Fundamentals of Python: First Programs, © 2024 Cengage Learning, Inc. ALL RIGHTS RESERVED.
Third Edition Previous edition(s): © 2015, © 2012.
Kenneth A. Lambert WCN: 02-300
No part of this work covered by the copyright herein may be reproduced
or distributed in any form or by any means, except as permitted by U.S.
SVP, Product: Cheryl Costantini copyright law, without the prior written permission of the copyright owner.

VP, Product: Thais Alencar Unless otherwise noted, all content is Copyright © Cengage Learning, Inc.

Portfolio Product Director: Rita Lombard The names of all products mentioned herein are used for identification
purposes only and may be trademarks or registered trademarks of their
Portfolio Product Manager: Tran Pham respective owners. Cengage Learning disclaims any affiliation, association,
connection with, sponsorship, or endorsement by such owners.
Product Assistant: Anh Nguyen

Learning Designer: Mary Convertino

For product information and technology assistance, contact us at


Senior Content Manager: Michelle Ruelos
Cengage Customer & Sales Support, 1-800-354-9706
Cannistraci
or support.cengage.com.

Digital Project Manager: John Smigelski


For permission to use material from this text or product, submit all
Technical Editor: Danielle Shaw requests online at www.copyright.com.

Developmental Editor: Spencer Peppet

VP, Product Marketing: Jason Sakos Library of Congress Control Number: 2023904384

Director, Product Marketing: Danae April


ISBN: 978-0-357-88101-9
Product Marketing Manager: Mackenzie Paine

Content Acquisition Analyst: Ann Hoffman Cengage


200 Pier 4 Boulevard
Production Service: Straive
Boston, MA 02210

Designer: Erin Griffin USA

Cover Image Source: Armagadon/shutterstock.com Cengage is a leading provider of customized learning solutions.
Our employees reside in nearly 40 different countries and serve digital
learners in 165 countries around the world. Find your local representative at:
www.cengage.com.

To learn more about Cengage platforms and services, register or access


your online learning solution, or purchase materials for your course,
visit www.cengage.com.

Notice to the Reader


Publisher does not warrant or guarantee any of the products described herein or perform any independent analysis in connection
with any of the product information contained herein. Publisher does not assume, and expressly disclaims, any obligation to obtain
and include information other than that provided to it by the manufacturer. The reader is expressly warned to consider and adopt
all safety precautions that might be indicated by the activities described herein and to avoid all potential hazards. By following
the instructions contained herein, the reader willingly assumes all risks in connection with such instructions. The publisher makes
no representations or warranties of any kind, including but not limited to, the warranties of fitness for particular purpose or
merchantability, nor are any such representations implied with respect to the material set forth herein, and the publisher takes no
responsibility with respect to such material. The publisher shall not be liable for any special, consequential, or exemplary damages
resulting, in whole or part, from the readers’ use of, or reliance upon, this material.

Printed in the United States of America


Print Number: 01 Print Year: 2023

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Brief Contents
About the Authorxi
Prefacexiii

Chapter 1 Introduction����������������������������������������������������������������������������������������������������� 1

Chapter 2 Software Development, Data Types, and Expressions�����������������������������27

Chapter 3 Loops and Selection Statements�����������������������������������������������������������������53

Chapter 4 Strings and Text Files������������������������������������������������������������������������������������87

Chapter 5 Lists and Dictionaries���������������������������������������������������������������������������������115

Chapter 6 Design with Functions��������������������������������������������������������������������������������145

Chapter 7 Design with Recursion��������������������������������������������������������������������������������165

Chapter 8 Simple Graphics and Image Processing���������������������������������������������������189

Chapter 9 Graphical User Interfaces��������������������������������������������������������������������������223

Chapter 10 Design with Classes����������������������������������������������������������������������������������265

Chapter 11 Data Analysis and Visualization��������������������������������������������������������������321

Chapter 12 Multithreading, Networks, and Client/Server Programming���������������357

Chapter 13 Searching, Sorting, and Complexity Analysis����������������������������������������393

Appendix A Python Resources������������������������������������������������������������������������������������429

Appendix B Installing the images and breezypythongui Libraries��������������������431

Appendix C The API for Image Processing�����������������������������������������������������������������433

Appendix D Transition from Python to Java and C++�����������������������������������������������435

Appendix E Suggestions for Further Reading����������������������������������������������������������� 437

Glossary439
Index453

iii

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents
About the Author xi
Preface xiii

Chapter 1
Introduction 1
1.1 T
 wo Fundamental Ideas of Personal Computing and Networks (1975–1990) 12
Computer Science: Algorithms and Consultation, Communication, and E-Commerce
Information Processing 1 (1990–2000) 14
Algorithms 2 Mobile Applications and Ubiquitous Computing
Information Processing 3 (2000–present) 15

1.2 T
 he Structure of a Modern 1.4 G
 etting Started with Python
Computer System 4 Programming16
Computer Hardware 4 Running Code in the Interactive Shell 16

Computer Software 5 Input, Processing, and Output 18


Editing, Saving, and Running a Script 19
1.3 A
 Not-So-Brief History of
Behind the Scenes: How Python Works 20
Computing Systems 7
Detecting and Correcting Syntax Errors 21
Before Electronic Digital Computers 8
Summary 22
Human Beings as Computers (1940–1945) 10
Key Terms 23
The First Electronic Digital Computers (1940–1950) 10
Review Questions 24
The First Programming Languages (1950–1965) 11
Programming Exercises 25
Integrated Circuits, Interaction, Time-Sharing, and
Software Engineering (1965–1975) 12 Debugging Exercise 25

Chapter 2
Software Development, Data Types, and Expressions 27
2.1 T
 he Software Development 2.3 N
 umeric Data Types and
Process27 Character Sets 37
2.2 S
 trings, Assignment, and Integers 37
Comments32 Floating-Point Numbers 37
Data Types 33 Character Sets 38
String Literals 33 2.4 Expressions 39
Escape Sequences 34 Arithmetic Expressions 39
String Concatenation 34 Mixed-Mode Arithmetic and Type Conversions 41
Variables and the Assignment Statement 35
2.5 Using Functions and Modules 43
Program Comments and Docstrings 36
Calling Functions: Arguments and Return Values 43

iv

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents v

The math Module 44 Summary 48


The Main Module 45 Key Terms 49
Program Format and Structure 46 Review Questions 49
Running a Script from a Terminal Programming Exercises 50
Command Prompt 46 Debugging Exercise 51

Chapter 3
Loops and Selection Statements 53
3.1 Definite Iteration: The for Loop 53 Logical Operators and Compound Boolean
Expressions 68
Executing a Statement a Given Number of Times 54
Short-Circuit Evaluation 70
Count-Controlled Loops 55
Testing Selection Statements 70
Augmented Assignment 56
Loop Errors: Off-by-One Error 56 3.4 C
 onditional Iteration: The while
Traversing the Contents of a Data Sequence 57 Loop71
Specifying the Steps in the Range 57 The Structure and Behavior of a while Loop 72

Loops That Count Down 58 Count Control with a while Loop 73


The while True Loop and the break
3.2 Formatting Text for Output 58
Statement 74
3.3 Selection: if and if-else Random Numbers 75
Statements64 Loop Logic, Errors, and Testing 76
The Boolean Type, Comparisons, and Boolean Summary 81
Expressions 64
Key Terms 82
if-else Statements 65
Review Questions 82
One-Way Selection Statements 66
Programming Exercises 84
Multiway if Statements 67
Debugging Exercise 86

Chapter 4
Strings and Text Files 87
4.1 A
 ccessing Characters and Converting Binary to Decimal 94
Substrings in Strings 87 Converting Decimal to Binary 95
The Structure of Strings 87 Conversion Shortcuts 95
The Subscript Operator 88 Octal and Hexadecimal Numbers 96
Slicing for Substrings 89 4.4 String Methods 97
Testing for a Substring with in Operator 90
4.5 Text Files 100
4.2 Data Encryption 91 Text Files and Their Format 100
4.3 Strings and Number Systems 93 Writing Text to a File 101
The Positional System for Representing Writing Numbers to a File 101
Numbers 93 Reading Text from a File 101

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi Contents

Reading Numbers from a File 102 Key Terms 112


Accessing and Manipulating Files and Review Questions 112
Directories on Disk 104 Programming Exercises 113
Summary 111 Debugging Exercise 114

Chapter 5
Lists and Dictionaries 115
5.1 Lists 115 The return Statement 127
List Literals and Basic Operators 116 Boolean Functions 127
Replacing an Element in a List 118 Defining a main Function 127
List Methods for Inserting and Removing 5.3 Dictionaries 132
Elements 119
Dictionary Literals 132
Searching a List 120
Adding Keys and Replacing Values 132
Sorting a List 121
Accessing Values 133
Mutator Methods and the Value None 121
Removing Keys 133
Aliasing and Side Effects 122
Traversing a Dictionary 133
Equality: Object Identity and Structural
Example: The Hexadecimal System Revisited 134
Equivalence 123
Example: Finding the Mode of a List
Example: Using a List to Find the Median of
of Values 135
a Set of Numbers 123
Summary 141
Tuples 124
Key Terms 142
5.2 Defining Simple Functions 126 Review Questions 142
The Syntax of Simple Function Definitions 126 Programming Exercises 143
Parameters and Arguments 127 Debugging Exercise 144

Chapter 6
Design with Functions 145
6.1 A
 Quick Review of What Functions 6.3 M
 anaging a Program’s
Are and How They Work 145 Namespace156
Functions as Abstraction Mechanisms 146 Module Variables, Parameters, and
Functions Eliminate Redundancy 146 Temporary Variables 156

Functions Hide Complexity 147 Scope 157

Functions Support General Methods with Lifetime 157


Systematic Variations 147 Using Keywords for Default and Optional
Functions Support the Division of Labor 148 Arguments 158
Summary 161
6.2 P
 roblem Solving with
Top-Down Design 148 Key Terms 161
Review Questions 162
The Design of the Text Analysis Program 148
Programming Exercises 163
The Design of the Sentence Generator Program 149
Debugging Exercise 164
The Design of the Doctor Program 150

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents vii

Chapter 7
Design with Recursion 165
7.1 Design with Recursive Functions 165 Mapping 180
Defining a Recursive Function 166 Filtering 181
Recursive Algorithms 167 Reducing 181
Tracing a Recursive Function 167 Using lambda to Create Anonymous Functions 182
Using Recursive Definitions to Construct Creating Jump Tables 182
Recursive Functions 168 Summary 185
Recursion in Sentence Structure 168 Key Terms 185
Infinite Recursion 170 Review Questions 186
The Costs and Benefits of Recursion 170 Programming Exercises 187
7.2 Higher-Order Functions 179 Debugging Exercise 188
Functions as First-Class Data Objects 179

Chapter 8
Simple Graphics and Image Processing 189
8.1 Simple Graphics 189 Image-Manipulation Operations 205
Overview of Turtle Graphics 190 The Properties of Images 205
Turtle Operations 190 The images Module 205
Setting Up a turtle.cfg File and Running IDLE 192 A Loop Pattern for Traversing a Grid 208
Object Instantiation and the turtle Module 192 A Word on Tuples 209
Drawing Two-Dimensional Shapes 194 Converting an Image to Black and White 209
Examining an Object’s Attributes 195 Converting an Image to Grayscale 210
Manipulating a Turtle’s Screen 196 Copying an Image 211
Taking a Random Walk 196 Blurring an Image 212
Colors and the RGB System 197 Edge Detection 213
Example: Filling Radial Patterns with Random Reducing the Image Size 214
Colors 198 Summary 216
8.2 Image Processing 203 Key Terms 217
Analog and Digital Information 204 Review Questions 217
Sampling and Digitizing Images 204 Programming Exercises 218
Image File Formats 204 Debugging Exercise 221

Chapter 9
Graphical User Interfaces 223
9.1 T
 he Behavior of Terminal-Based 9.2 C
 oding Simple GUI-Based
Programs and GUI-Based Programs226
Programs224 A Simple “Hello World” Program 227
The Terminal-Based Version 224 A Template for All GUI Programs 228
The GUI-Based Version 225 The Syntax of Class and Method Definitions 228
Event-Driven Programming 226 Subclassing and Inheritance as Abstraction
Mechanisms 229
Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii Contents

9.3 W
 indows and Window Using Nested Frames to Organize
Components229 Components 247
Windows and Their Attributes 230 Multiline Text Areas 248
Window Layout 230 File Dialogs 250
Types of Window Components and Their Obtaining Input with Prompter Boxes 252
Attributes 232 Check Buttons 253
Displaying Images 233 Radio Buttons 254
9.4 C
 ommand Buttons and Keyboard Events 256
Responding to Events 235 Working with Colors 256
9.5 I nput and Output with Entry Using a Color Chooser 258
Fields237 Summary 260
Text Fields 237 Key Terms 260
Integer and Float Fields for Numeric Data 238 Review Questions 261
9.6 D
 efining and Using Instance Programming Exercises 262
Variables240 Debugging Exercise 263

9.7 O
 ther Useful GUI Resources 246

Chapter 10
Design with Classes 265
10.1 G
 etting Inside Objects and Input of Objects and the try-except
Classes266 Statement 289

A First Example: The Student Class 266 Playing Cards 290

Docstrings 268 10.3 B


 uilding a New Data Structure:
Method Definitions 269 The Two-Dimensional Grid 298
The __init__ Method and Instance The Interface of the Grid Class 298
Variables 269 The Implementation of the Grid Class:
The __str__ Method 269 Instance Variables for the Data 300
Accessors and Mutators 270 The Implementation of the Grid Class:
The Lifetime of Objects 270 Subscript and Search 301

Rules of Thumb for Defining a 10.4 S


 tructuring Classes with
Simple Class 271 Inheritance and Polymorphism 305
10.2 Data-Modeling Examples 279 Inheritance Hierarchies and Modeling 305

Rational Numbers 279 Example 1: A Restricted Savings Account 306

Rational Number Arithmetic and Operator Example 2: The Dealer and a Player in the
Overloading 281 Game of Blackjack 308

Comparison Methods 282 Polymorphic Methods 312

Equality and the __eq__ Method 282 The Costs and Benefits of Object-Oriented
Programming 312
The __repr__ Method for Printing an Object
in IDLE 283 Summary 315
Savings Accounts and Class Variables 284 Key Terms 316
Putting the Accounts into a Bank 286 Review Questions 317
Using pickle for Permanent Storage Programming Exercises 318
of Objects 288 Debugging Exercise 320

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents ix

Chapter 11
Data Analysis and Visualization 321
11.1 S
 ome Basic Functions for 11.3 W
 orking with More Complex
Analyzing a Data Set 322 Data Sets 343
Computing the Maximum, Minimum, and Mean 323 Creating a Data Set with pandas 344
Computing the Median 323 Visualizing Data with pandas and
Computing the Mode and Modes 324 matplotlib.pyplot 344

Computing the Standard Deviation 325 Accessing Columns and Rows in a Data Frame 345

Using the NumPy Library 326 Creating a Data Frame from a CSV File 346
Cleaning the Data in a Data Frame 347
11.2 Visualizing a Data Set 333
Accessing Other Attributes of a Data Frame 348
Pie Charts 335
Summary 354
Bar Charts 337
Key Terms 354
Scatter Plots 339
Review Questions 354
Line Plots 340
Programming Exercises 355
Histograms 342

Chapter 12
Multithreading, Networks, and Client/Server Programming 357
12.1 Threads and Processes 357 12.3 N
 etworks, Clients, and
Threads 358 Servers374
Sleeping Threads 360 IP Addresses 374
Producer, Consumer, and Synchronization 362 Ports, Servers, and Clients 375
Sockets and a Day/Time Client Script 375
12.2 T
 he Readers and Writers
Problem368 A Day/Time Server Script 377

Using the SharedCell Class 369 A Two-Way Chat Script 379

Implementing the Interface of the SharedCell Handling Multiple Clients Concurrently 380
Class 370 Summary 388
Implementing the Helper Methods of the Key Terms 389
SharedCell Class 371 Review Questions 389
Testing the SharedCell Class with Programming Exercises 390
a Counter Object 372
Debugging Exercise 392
Defining a Thread-Safe Class 373

Chapter 13
Searching, Sorting, and Complexity Analysis 393
13.1 M
 easuring the Efficiency of 13.2 Complexity Analysis 398
Algorithms394 Orders of Complexity 398
Measuring the Run Time of an Algorithm 394 Big-O Notation 400
Counting Instructions 396

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x Contents

The Role of the Constant of Proportionality 400 Quicksort 410


Measuring the Memory Used by an Algorithm 400 Partitioning 410
13.3 Search Algorithms 401 Complexity Analysis of Quicksort 410

Search for a Minimum 401 Implementation of Quicksort 411

Sequential Search of a List 402 Merge Sort 413

Best-Case, Worst-Case, and Average-Case Implementing the Merging Process 413


Performance 403 Complexity Analysis of Merge Sort 416
Binary Search of a List 403 13.6 A
 n Exponential Algorithm:
13.4 Basic Sort Algorithms 405 Recursive Fibonacci 416
Selection Sort 405 Converting Fibonacci to a Linear Algorithm 417

Bubble Sort 406 Summary 423

Insertion Sort 408 Key Terms 424

Best-Case, Worst-Case, and Average-Case Review Questions 424


Performance Revisited 409 Programming Exercises 425
13.5 Faster Sorting 409

Appendix A
Python Resources 429

Appendix B
Installing the images and breezypythongui Libraries 431

Appendix C
The API for Image Processing 433

Appendix D
Transition from Python to Java and C++ 435

Appendix E
Suggestions for Further Reading 437

Glossary439
Index453

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
About the Author
Kenneth A. Lambert is Professor of Computer Science Emeritus at Washington and Lee University. He taught
introductory programming courses for 37 years and has been an active researcher in computer science educa-
tion. Lambert has co-authored a series of introductory C++ textbooks with Douglas Nance and Thomas Naps
and a series of introductory Java textbooks with Martin Osborne. He is the author of Python textbooks for CS1
and CS2 college-level courses and a Python textbook for teens. He is also the co-creator of the BreezySwing
framework and is the creator of the breezypythongui framework.

Dedication
To my grandchildren—Lucy, Wyatt, Cuba, and Van
Kenneth A. Lambert
Lexington, VA

xi

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface
“Everyone should learn how to code.” That’s my favorite quote from Suzanne Keen, formerly the Thomas
Broadus Professor of English and Dean of the College at Washington and Lee University, where I have taught
computer science for more than 30 years. The quote also states the reason why I wrote the first and second
editions of Fundamentals of Python: First Programs, and why I now offer you this third edition. The book is
intended for an introductory course in programming and problem solving. It covers the material taught in a
typical Computer Science 1 (CS1) course at the undergraduate or high school level.

This book covers five major aspects of computing:

1. Programming basics—Data types, control structures, algorithm development, and program


design with functions are basic ideas that you need to master in order to solve problems with
computers. This book examines these core topics in detail and gives you practice employing your
understanding of them to solve a wide range of problems.
2. Object-oriented programming (OOP)—Object-oriented programming is the dominant programming
paradigm used to develop large software systems. This book introduces you to the fundamental
principles of OOP and enables you to apply them successfully.
3. Data and information processing—Most useful programs rely on data structures to solve
problems. These data structures include strings, arrays, files, lists, and dictionaries. This book
introduces you to these commonly used data structures and includes examples that illustrate
criteria for selecting the appropriate data structures for given problems.
4. Software development life cycle—Rather than isolate software development techniques in one
or two chapters, this book deals with them throughout in the context of numerous case studies.
Among other things, you’ll learn that coding a program is often not the most difficult or challenging
aspect of problem solving and software development.
5. Contemporary applications of computing—The best way to learn about programming and
problem solving is to create interesting programs with real-world applications. In this book, you’ll
begin by creating applications that involve numerical problems and text processing. For example,
you’ll learn the basics of encryption techniques, such as those that are used to make your credit
card number and other information secure on the Internet. But unlike many other introductory
texts, this one does not restrict itself to problems involving numbers and text. Most contemporary
applications involve graphical user interfaces, event-driven programming, graphics, image
manipulation, network communications, and data analysis. These topics are not consigned to the
margins but are presented in depth after you have mastered the basics of programming.

Why Python?
Computer technology and applications have become increasingly more sophisticated over the past three
decades, and so has the computer science curriculum, especially at the introductory level. Today’s students
learn a bit of programming and problem solving and are then expected to move quickly into topics like software
development, complexity analysis, and data structures that 35 years ago were relegated to advanced courses.
In addition, the ascent of object-oriented programming as the dominant paradigm of problem solving has led
instructors and textbook authors to implant powerful, industrial-strength programming languages such as

xiii

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv Preface

C++ and Java in the introductory curriculum. As a result, instead of experiencing the rewards and excitement of solving
problems with computers, beginning computer science students often become overwhelmed by the combined tasks
of mastering advanced concepts as well as the syntax of a programming language.

This book uses the Python programming language as a way of making the first year of studying computer science
more manageable and attractive for students and instructors alike. Python has the following pedagogical benefits:

• Python has simple, conventional syntax. Python statements are very close to those of pseudocode algorithms,
and Python expressions use the conventional notation found in algebra. Thus, students can spend less time
learning the syntax of a programming language and more time learning to solve interesting problems.
• Python has safe semantics. Any expression or statement whose meaning violates the definition of the language
produces an error message.
• Python scales well. It is very easy for beginners to write simple programs in Python. Python also includes all
of the advanced features of a modern programming language, such as support for data structures and object-
oriented software development, for use when they become necessary.
• Python is highly interactive. Expressions and statements can be entered at an interpreter’s prompts to allow the
programmer to try out experimental code and receive immediate feedback. Longer code segments can then be
composed and saved in script files to be loaded and run as modules or standalone applications.
• Python is general purpose. In today’s context, this means that the language includes resources for
contemporary applications, including media computing and networks.
• Python is free and is in widespread use in industry. Students can download Python to run on a variety of
devices. There is a large Python user community, and expertise in Python programming has great résumé value.

To summarize these benefits, Python is a comfortable and flexible vehicle for expressing ideas about computation,
both for beginners and for experts. If students learn these ideas well in the first course, they should have no problems
making a quick transition to other languages needed for courses later in the curriculum. Most importantly, beginning
students will spend less time staring at a computer screen and more time thinking about interesting problems to solve.

Organization of the Text


The approach of this text is easygoing, with each new concept introduced only when it is needed.

Chapter 1 introduces computer science by focusing on two fundamental ideas, algorithms and information pro-
cessing. A brief overview of computer hardware and software, followed by an extended discussion of the history of
computing, sets the context for computational problem solving.

Chapters 2 and 3 cover the basics of problem solving and algorithm development using the standard control
structures of expression evaluation, sequencing, Boolean logic, selection, and iteration with the basic numeric data
types. Emphasis in these chapters is on problem solving that is both systematic and experimental, involving algorithm
design, testing, and documentation.

Chapters 4 and 5 introduce the use of the strings, text files, lists, and dictionaries. These data structures are both
remarkably easy to manipulate in Python and support some interesting applications. Chapter 5 also introduces simple
function definitions as a way of organizing algorithmic code.

Chapter 6 explores the technique and benefits of procedural abstraction with function definitions. Top-down design
and stepwise refinement with functions are examined as means of structuring code to solve complex problems. Details
of namespace organization (parameters, temporary variables, and module variables) and communication among soft-
ware components are discussed.

Chapter 7 examines recursive design with functions. A section on functional programming with higher-order func-
tions shows how to exploit functional design patterns to simplify solutions.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xv

Chapter 8 focuses on the use of existing objects and classes to compose programs. Special attention is paid to
the application programming interface (API), or set of methods, of a class of objects and the manner in which objects
cooperate to solve problems. This chapter also introduces two contemporary applications of computing: graphics and
image processing. These are areas in which object-based programming is particularly useful.

Chapter 9 introduces the definition of new classes to construct graphical user interfaces (GUIs). The chapter
contrasts the event-driven model of GUI programs with the process-driven model of terminal-based programs. The
chapter explores the creation and layout of GUI components, as well as the design of GUI-based applications using
the model/view pattern. The initial approach to defining new classes in this chapter is unusual for an introductory
textbook: students learn that the easiest way to define a new class is to customize an existing class using subclassing
and inheritance.

Chapter 10 continues the exploration of object-oriented design with the definition of entirely new classes. Several
examples of simple class definitions from different application domains are presented. Some of these are then inte-
grated into more realistic applications to show how object-oriented software components can be used to build complex
systems. Emphasis is on designing appropriate interfaces for classes that exploit polymorphism.

Chapter 11 introduces tools and techniques for performing data analysis, a fast-growing application area of com-
puter science. Topics include the acquisition and cleaning of data sets, applying functions to determine relationships
among data, and deploying graphs, plots, and charts to visualize these relationships.

Chapter 12 covers advanced material related to several important areas of computing: concurrent programming,
networks, and client/server applications. This chapter thus gives students challenging experiences near the end of the
first course. This chapter introduces multithreaded programs and the construction of simple network-based client/
server applications.

Chapter 13 covers some topics addressed at the beginning of a traditional CS2 course. This chapter introduces
complexity analysis with big-O notation. Enough material is presented to enable you to perform simple analyses of
the running time and memory usage of algorithms and data structures, using search and sort algorithms as examples.

New to This Edition


The third edition includes the following new or updated content and features:

• A new chapter (Chapter 7) on design with recursion. This chapter incorporates and expands on material on
recursive functions and higher-order functions from Chapter 6 of the second edition.
• A new chapter (Chapter 11) on data analysis and visualization. This chapter introduces tools and techniques
for acquiring data sets, cleaning them, and applying functions to them to determine relationships which can be
visualized in plots, charts, and graphs.
• Updated coverage of the history of computing in Chapter 1.
• New fail-safe programming sections added to most chapters to demonstrate best practices for programming
securely.
• New list of key terms in each chapter.
• Updated end-of-chapter review questions and programming exercises.
• End-of-chapter programming exercises mapped to the learning objectives for each chapter.
• New debugging exercises in each chapter provide examples of challenging programming errors and give you
experience in diagnosing and correcting them.
• Several new case studies as well as new or updated programming exercises.
• Text revisions throughout with a focus on readability.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvi Preface

Features of the Text


This book explains and develops concepts carefully, using frequent examples and diagrams. New concepts are then
applied in complete programs to show how they aid in solving problems. The chapters place an early and consistent
emphasis on good writing habits and neat, readable documentation.

The book includes several other important features:

• Chapter Objectives: Each chapter begins with a set of learning objectives which describe the skills and
concepts you will acquire from a careful reading of the chapter.
• Chapter Summary: Each chapter ends with a summary of the major concepts covered in the chapter.
• Key Terms: When a technical term is introduced in the text, it appears in boldface. The list of terms appears
after the chapter summary. Definitions of the key terms are provided in the glossary.

Exercise

Exercises: Most major sections of each chapter end with exercise questions that reinforce the reading by asking
basic questions about the material in the section.

Case Study
Case Studies: The Case Studies present complete Python programs ranging from the simple to the
substantial. To emphasize the importance and usefulness of the software development life cycle, case
studies are discussed in the framework of a user request, followed by analysis, design, implementation, and
suggestions for testing, with well-defined tasks performed at each stage. Some case studies are extended in
end-of-chapter programming exercises.

Fail-Safe Programming

Fail-Safe Programming: Fail-Safe Programming sections include a discussion of ways to make a program
detect and respond gracefully to disturbances in its runtime environment.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xvii

Review Questions
Review Questions: Multiple-choice review questions allow you to revisit the concepts presented in each
chapter.

Programming Exercises
Programming Exercises: Each chapter ends with a set of programming projects of varying difficulty. Each
programming exercise is mapped to one or more relevant chapter learning objectives and gives you the
opportunity to design and implement a complete program that utilizes major concepts presented in that
chapter.

Debugging Exercises
Debugging Exercises: Debugging exercises illustrate a typical program error with suggestions for repairing it.

• A software toolkit for image processing: This book comes with an open-source Python toolkit for the easy
image processing discussed in Chapter 8. The toolkit can be obtained with the ancillaries at www.cengage.com
or at https://kennethalambert.com/python/
• A software toolkit for GUI programming: This book comes with an open-source Python toolkit for the easy GUI
programming introduced in Chapter 9. The toolkit can be obtained with the ancillaries at www.cengage.com or
at https://kennethalambert.com/breezypythongui/
• Appendices: Five appendices include information on obtaining Python resources, installing the toolkits, using
the toolkits’ interfaces, and suggestions for further reading.
• Glossary: Definitions of key terms are collected in a glossary.

Inclusivity and Diversity


Cengage is committed to providing educational content that is inclusive and welcoming to all learners. Research
demonstrates that students who experience a sense of belonging in class more successfully make meaning out of, and
find relevance in, what they encounter in learning content. To improve both the learning process and outcomes, our

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xviii Preface

materials seek to affirm the fullness of human diversity with respect to ability, language, culture, gender, age, socio-
economics, and other forms of human difference that students may bring to the classroom.

Across the computing industry, standard coding language, such as “Master” and “Slave” is being retired in favor of lan-
guage that is more inclusive, such as “Supervisor/Worker,” “Primary/Replica,” or “Leader/Follower.” At this time, different
software development and social media companies are adopting their own replacement language and currently there is no
shared standard. In addition, the terms “Master” and “Slave” remain deeply embedded in legacy code and understanding
this terminology remains necessary for new programmers. When required for understanding, Cengage will introduce the
non-inclusive term in the first instance but will then provide an appropriate replacement terminology for the remainder of
the discussion or example. We appreciate your feedback as we work to make our products more inclusive for all.

For more information about Cengage’s commitment to inclusivity and diversity, please visit https://www.cengage
.com/inclusion-diversity/

Course Solutions
Online Learning Platform: MindTap
Today’s leading online learning platform, MindTap for Fundamentals of Python, Third Edition provides complete con-
trol to craft a personalized, engaging learning experience that challenges students, builds confidence, and elevates
performance.

MindTap introduces students to core concepts from the beginning of the course, using a simplified learning path
that progresses from understanding to application and delivers access to eTextbooks, study tools, interactive media,
auto-graded assessments, and performance analytics.

MindTap activities for Fundamentals of Python: First Programs are designed to help students build the skills needed
in today’s workforce. Research shows employers seek critical thinkers, troubleshooters, and creative problem-solvers
to stay relevant in our fast-paced, technology-driven world. MindTap achieves this with assignments and activities
that provide hands-on practice and real-life relevance. Students are guided through assignments that reinforce basic
knowledge and understanding before moving on to more challenging problems.

All MindTap activities and assignments are tied to defined chapter learning objectives. Hands-on coding labs pro-
vide real-life application and practice. Readings and dynamic visualizations support the lecture, while a post-course
assessment measures exactly how much a student has learned. MindTap provides the analytics and reporting to easily
see where the class stands in terms of progress, engagement, and completion rates. The content and learning path
can be used as provided, customized directly in the MindTap platform, or integrated into the Learning Management
System (LMS) to meet the needs of a particular course . Instructors can control what students see and when they see
it. Learn more at https://www.cengage.com/mindtap.

In addition to the readings, the MindTap for Fundamentals of Python: First Programs, Third Edition includes the following:

• Coding labs. These supplemental assignments provide real-world application and encourage students to
practice new programming concepts in a complete online IDE. New and improved Guided Feedback provides
personalized and immediate feedback to students as they proceed through their coding assignments so that
they can understand and correct errors in their code.
• Gradeable assessments and activities. All assessments and activities from the readings are available as
gradeable assignments within MindTap, including Exercises and Review Questions.
• Video quizzes. These graded assessments provide a visual explanation of foundational programming concepts
that can be applied across multiple languages. Questions accompany each video to confirm understanding of
new material.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xix

• Interactive activities. These embedded interactive flowcharts, tabbed explorations, and click-to-reveal
experiences are designed to engage students and help them assess their understanding of introductory
computer science concepts as they progress through their chapter readings.
• Interactive study aids. Flashcards and PowerPoint lectures help users review main concepts from the units.

Supplemental Package
Instructor and Student Resources
Additional instructor and student resources for this product are available online.

Instructor assets include an Instructor’s Manual, Educator’s Guide, PowerPoint® slides, and a test bank powered
by Cognero®. Student assets include data sets. Sign up or sign in at www.cengage.com to search for and access this
product and its online resources.

• Instructor Manual. The Instructor Manual that accompanies this textbook includes additional instructional
material to assist in class preparation, including items such as Overviews, Chapter Objectives, Teaching Tips,
Quick Quizzes, Class Discussion Topics, Additional Projects, Additional Resources, and Key Terms.
• Test Bank. Cengage Testing Powered by Cognero is a flexible, online system that allows you to:
■ Author, edit, and manage test bank content from multiple Cengage solutions.
■ Create multiple test versions in an instant.
■ Deliver tests from your LMS, your classroom, or wherever you want.

• PowerPoint Presentations. This text provides PowerPoint slides to accompany each chapter. Slides may
be used to guide classroom presentations, to make available to students for chapter review, or to print as
classroom handouts. Files are provided for every figure in the text. Instructors may use the files to customize
PowerPoint slides, illustrate quizzes, or create handouts.
• Solution and Answer Guide. Solutions and rationales to review questions and exercises are provided to assist
with grading and student understanding.
• Solutions. Solutions to all programming exercises and case studies are available. If an input file is needed to run
a programming exercise, it is included with the solution file.
• Data Files. Data files necessary to complete some of the steps in the programming exercises are available. If an
input file is needed to run a program, it is included with the source code.
• Educator’s Guide. The Educator’s Guide contains a detailed outline of the corresponding MindTap course.
• Transition Guide. The Transition Guide outlines information on what has changed from the Second Edition.

Supplements can be found at https://faculty.cengage.com/. Sign In or create an account, then search for this title.
You can save the title for easy access and then download the resources that you need.

Acknowledgments
I would like to thank my good friend, Martin Osborne, for many years of advice, friendly criticism, and encourage-
ment on several of my book projects. I am also grateful to the many students and faculty colleagues at Washington
and Lee University who have used earlier editions of this book and given helpful feedback on it over the life of those
editions.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xx Preface

In addition, I would like to thank the following reviewers for the time and effort they contributed to Fundamentals
of Python: Eric Williamson, Liberty University and Jason Carman, Horry, Georgetown Technical College.

Thank you also to Danielle Shaw, who helped to assure that the content of all data and solution files used for this
text were correct and accurate.

Finally, thanks to the individuals at Cengage who made this book possible: Tran Pham, Product Manager; Mary
Convertino, Learning Designer; Michelle Ruelos Cannistraci, Senior Content Manager; Troy Dundas, Technical C
­ ontent
Developer; Spencer Peppet, Developmental Editor; Ann Shaffer, Developmental Editor; and Ethan Wheel, Product
Assistant.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Chapter 1

Introduction
Learning Objectives
When you complete this chapter, you will be able to:
› 1.1 Describe the basic features of an algorithm
› 1.2 Explain how hardware and software collaborate in a computer’s architecture
› 1.3 Summarize a brief history of computing
› 1.4 Compose and run a simple Python program

As a reader of this book, you almost certainly have played a video game and listened to digital music. It’s likely
that you have watched a movie on Netflix after preparing a snack in a microwave. Chances are that today you
will make a phone call, send or receive a text message, take a photo, or consult your favorite social network
on a smartphone, which is a small computer. You and your friends have most likely used a desktop or laptop
computer to do significant coursework in high school or college.

Computer technology is almost everywhere: in our homes, schools, and in the places where we work
and play. Computer technology is essential to modern entertainment, education, medicine, manufacturing,
communications, government, and commerce. We have digital lifestyles in an information-based economy.
Some people even claim that nature itself performs computations on information structures present in DNA
and in the relationships among subatomic particles.

In the following chapters you will learn about computer science, which is the study of computation that has
made this new technology and this new world possible. You will also learn how to use computers effectively
and appropriately to enhance your own life and the lives of others.

1.1 T
 wo Fundamental Ideas of Computer Science:
Algorithms and Information Processing
Like most areas of study, computer science focuses on a broad set of interrelated ideas. Two of the most basic
ones are algorithms and information processing. In this section, these ideas are introduced in an informal way.
You will examine them in more detail in later chapters.

1
1

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2 Chapter 1 Introduction

Algorithms
People computed long before the invention of modern computing devices, and many continue to use devices that we
might consider primitive. For example, consider how merchants made change for customers in marketplaces before
the existence of credit cards, pocket calculators, or cash registers. Making change can be a complex activity. It takes
some mental effort to get it right every time. Let’s consider what’s involved in this process.

According to one method, the first step is to compute the difference between the purchase price and the amount
of money that the customer gives the merchant. The result of this calculation is the total amount that the merchant
must return to the purchaser. For example, if you buy a dozen eggs at the farmers’ market for $2.39 and you give the
farmer a $10 bill, she should return $7.61 to you. To produce this amount, the merchant selects the appropriate coins
and bills that add up to $7.61.

According to another method, the merchant starts with the purchase price and goes toward the amount
given. First, coins are selected to bring the price to the next dollar amount (in this case, $0.61 = 2 quarters, 1
dime, and 1 penny), then dollars are selected to bring the price to the next five-dollar amount (in this case,
$2), and then, in this case, a $5 bill completes the transaction. As you will see in this book, there can be many
possible methods or algorithms that solve the same problem, and the choice of the best one is a skill you will
acquire with practice.

Few people can subtract three-digit numbers without resorting to some manual aids, such as pencil and paper.
As you learned in grade school, you can carry out subtraction with pencil and paper by following a sequence of well-
defined steps. You have probably done this many times but never made a list of the specific steps involved. Making
such lists to solve problems is something computer scientists do all the time. For example, the following list of steps
describes the process of subtracting two numbers using a pencil and paper:

Step 1 Write down the two numbers, with the larger number above the smaller number and their digits aligned
in columns from the right.
Step 2 Assume that you will start with the rightmost column of digits and work your way left through the
various columns.
Step 3 Write down the difference between the two digits in the current column of digits, borrowing a 1 from
the top number’s next column to the left if necessary.
Step 4 If there is no next column to the left, stop. Otherwise, move to the next column to the left, and go back
to Step 3.

If the computing agent (in this case a human being) follows each of these simple steps correctly, the entire process
results in a correct solution to the given problem. We assume in Step 3 that the agent already knows how to compute
the difference between the two digits in any given column, borrowing if necessary.

To make change, most people can select the combination of coins and bills that represent the correct change amount
without any manual aids, other than the coins and bills. But the mental calculations involved can still be described in
a manner similar to the preceding steps, and we can resort to writing them down on paper if there is a dispute about
the correctness of the change.

The sequence of steps that describes each of these computational processes is called an algorithm. Informally,
an algorithm is like a recipe. It provides a set of instructions that tells us how to do something, such as make change,
bake bread, or put together a piece of furniture. More precisely, an algorithm describes a process that ends with a
solution to a problem. The algorithm is also one of the fundamental ideas of computer science. An algorithm has the
following features:

1. An algorithm consists of a finite number of instructions.


2. Each individual instruction in an algorithm is well defined. This means that the action described
by the instruction can be performed effectively or be executed by a computing agent. For example,

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.1 Two Fundamental Ideas of Computer Science: Algorithms and Information Processing 3

any computing agent capable of arithmetic can compute the difference between two digits. So, an
algorithmic step that says “compute the difference between two digits” would be well defined. On the
other hand, a step that says “divide a number by 0” is not well defined, because no computing agent
could carry it out.
3. An algorithm describes a process that eventually halts after arriving at a solution to a problem. For example,
the process of subtraction halts after the computing agent writes down the difference between the two
digits in the leftmost column of digits.
4. An algorithm solves a general class of problems. For example, an algorithm that describes how to make
change should work for any two amounts of money whose difference is greater than or equal to $0.00.

Creating a list of steps that describe how to make change might not seem like a major accomplishment to you. But the
ability to break a task down into its component parts is one of the main jobs of a computer programmer. Once you
write an algorithm to describe a particular type of computation, you can build a machine to do the computing. Put
another way, if you can develop an algorithm to solve a problem, you can automate the task of solving the problem.
You might not feel compelled to write a computer program to automate the task of making change, because you can
probably already make change yourself fairly easily. But suppose you needed to do a more complicated task—such as
sorting a list of 100 names. In that case, a computer program would be very handy.

Computers can be designed to run a small set of algorithms for performing specialized tasks, such as operating
a microwave. But we can also build computers, like the one on your desktop, that are capable of performing a
task described by any algorithm. These computers are truly general-purpose problem-solving machines. They
are unlike any machines that were built before, and they have formed the basis of the completely new world in
which we live.

Later in this book, we introduce a notation for expressing algorithms and some suggestions for designing algorithms.
You will see that algorithms and algorithmic thinking are critical underpinnings of any computer system.

Information Processing
Since people first learned to write several thousand years ago, they have processed information. Information itself
has taken many forms in its history, from the marks impressed on clay tablets in ancient Mesopotamia; to the first
written texts in ancient Greece; to the printed words in the books, newspapers, and magazines mass-produced
since the European Renaissance; to the abstract symbols of modern mathematics and science used during the
past 350 years. Only recently, however, have human beings developed the capacity to automate the processing of
information by building computers. In the modern world of computers, information is also commonly referred to
as data. But what is information?

Like mathematical calculations, information processing can be described with algorithms. In our earlier example
of making change, the subtraction steps involved manipulating symbols used to represent numbers and money. In
carrying out the instructions of any algorithm, a computing agent manipulates information. The computing agent
starts with some given information (known as input), transforms this information according to well-defined rules, and
produces new information, known as output.

It is important to recognize that the algorithms that describe information processing can also be represented as
information. Computer scientists have been able to represent algorithms in a form that can be executed effectively
and efficiently by machines. They have also designed real machines, called electronic digital computers, which are
capable of executing algorithms.

Computer scientists more recently discovered how to represent many other things, such as images, music, human
speech, and video, as information. Many of the media and communication devices that we now take for granted would be
impossible without this new kind of information processing. We examine many of these achievements in more detail in
later chapters.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4 Chapter 1 Introduction

Exercise 1-1

These short end-of-section exercises are intended to stimulate your thinking about computing.

1. List three common types of computing agents.

2. Write an algorithm that describes the second part of the process of making change (counting out the
coins and bills).

3. Write an algorithm that describes a common task, such as baking a cake.

4. Describe an instruction that is not well defined and thus could not be included as a step in an algorithm.
Give an example of such an instruction.

5. In what sense is a laptop computer a general-purpose problem-solving machine?

6. List four devices that use computers and describe the information that they process. (Hint: Think of the
inputs and outputs of the devices.)

1.2 The Structure of a Modern Computer System


We now give a brief overview of the structure of modern computer systems. A modern computer system consists of
hardware and software. Hardware consists of the physical devices required to execute algorithms. Software is the set
of these algorithms, represented as programs, in particular programming languages. In the discussion that follows,
we focus on the hardware and software found in a typical desktop computer system, although similar components are
also found in other computer systems, such as smartphones and automatic teller machines (ATMs).

Computer Hardware
The basic hardware components of a computer are memory, a central processing unit (CPU), and a set of
input/output devices, as shown in Figure 1-1.

Figure 1-1 Hardware components of a modern computer system

Input device Output device

Memory

CPU

Human users primarily interact with the input and output devices. The input devices include a keyboard, a mouse,
a trackpad, a microphone, and a touchscreen. Common output devices include a monitor and speakers. Computers can
also communicate with the external world through various ports that connect them to networks and to other devices
such as smartphones and digital cameras. The purpose of most input devices is to convert information that human
beings deal with, such as text, images, and sounds, into information for computational processing. The purpose of
most output devices is to convert the results of this processing back to human-usable form.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.2 The Structure of a Modern Computer System 5

Computer memory is set up to represent and store information in electronic form. Specifically, information is stored
as patterns of binary digits (1s and 0s). To understand how this works, consider a basic device such as a light switch,
which can only be in one of two states, on or off. Now suppose there is a bank of switches that control 16 small lights
in a row. By turning the switches off or on, we can represent any pattern of 16 binary digits (1s and 0s) as patterns of
lights that are on or off. As you will see later in this book, computer scientists have discovered how to represent any
information, including text, images, and sound, in binary form.

Now, suppose there are 8 of these groups of 16 lights. We can select any group of lights and examine or change the
state of each light within that collection. We have just developed a tiny model of computer memory. The memory has
8 cells, each of which can store 16 bits of binary information. A diagram of this model, in which the memory cells are
filled with binary digits, is shown in Figure 1-2. This memory is also sometimes called primary memory or internal
or random access memory (RAM).

Figure 1-2 A model of computer memory


Cell 7 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1
Cell 6 1 0 1 1 0 1 1 1 1 1 1 0 1 1 1 1
Cell 5 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1
Cell 4 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1
Cell 3 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1
Cell 2 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1
Cell 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1
Cell 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0

The information stored in memory can represent any type of data, such as numbers, text, images, sound, or the
instructions of a program. Once the information is stored in memory, we typically want to do something with it—that
is, we want to process it. The part of a computer that is responsible for processing data is the central processing unit
(CPU). This device, which is also sometimes called a processor, consists of electronic switches arranged to perform
simple logical, arithmetic, and control operations. The CPU executes an algorithm by fetching its binary instructions
from memory, decoding them, and executing them. Executing an instruction might involve fetching other binary
information—the data—from memory as well.

The processor can locate data in a computer’s primary memory very quickly. However, these data exist only as
long as electric power comes into the computer. If the power fails or is turned off, the data in primary memory are
lost. Clearly, a more permanent type of memory is needed to preserve data. This more permanent type of memory is
called external or secondary memory, and it comes in several forms. Magnetic storage media, such as tapes and hard
disks, allow bit patterns to be stored as patterns on a magnetic field. Semiconductor storage media, such as flash
memory sticks and universal serial bus (USB) drives, perform much the same function with a different technology,
as do optical storage media, such as compact disks (CDs) and digital video disks (DVDs). Some of these secondary
storage media can hold much larger quantities of information than the internal memory of a computer.

Computer Software
You have learned that a computer is a general-purpose problem-solving machine. To solve any computable problem,
a computer must be capable of executing any algorithm. Because it is impossible to anticipate all of the problems for
which there are algorithmic solutions, there is no way to hardwire all potential algorithms into a computer’s hardware.
Instead, some basic operations are built into the hardware’s processor and require any algorithm to use them. The
algorithms are converted to binary form and then loaded, with their data, into the computer’s memory. The processor
can then execute the algorithms’ instructions by running the hardware’s more basic operations.

Any programs that are stored in memory so that they can be executed later are called software. A program stored
in computer memory must be represented in binary digits, which is also known as machine code. Loading machine
code into computer memory one digit at a time would be a tedious, error-prone task for human beings. It would be

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
6 Chapter 1 Introduction

convenient if we could automate this process to get it right every time. For this reason, computer scientists have
developed another program, called a loader, to perform this task. A loader takes a set of machine language instructions
as input and loads them into the appropriate memory locations. When the loader is finished, the machine language
program is ready to execute. Obviously, the loader cannot load itself into memory, so this is one of those algorithms
that must be hardwired into the computer.

Now that a loader exists, you can load and execute other programs that make the development, execution, and
management of programs easier. This type of software is called system software. The most important example of system
software is a computer’s operating system. You are probably already familiar with at least one of the most popular
operating systems, such as Linux, Apple’s macOS, and Microsoft’s Windows. An operating system is responsible for
managing and scheduling several concurrently running programs. It also manages the computer’s memory, including the
external storage, and manages communications between the CPU, the input/output devices, and other computers on a
network. An important part of any operating system is its file system, which allows human users to organize their data and
programs in permanent storage. Another important function of an operating system is to provide user interfaces—that
is, ways for the human user to interact with the computer’s software. A terminal-based interface accepts inputs from a
keyboard and displays text output on a monitor screen. A graphical user interface (GUI) organizes the monitor screen
around the metaphor of a desktop, with windows containing icons for folders, files, and applications. This type of user
interface also allows the user to manipulate images with a pointing device such as a mouse. A touchscreen interface
supports more direct manipulation of these visual elements with gestures such as pinches and swipes of the user’s
fingers. Devices that respond verbally and in other ways to verbal commands are also becoming widespread.

Another major type of software is called applications software, or simply apps. An application is a program that is
designed for a specific task, such as editing a document or displaying a web page. Applications include web browsers,
word processors, spreadsheets, database managers, graphic design packages, music production systems, and games,
among millions of others. As you begin learning to write computer programs, you will focus on writing simple applications.

As you have learned, computer hardware can execute only instructions that are written in binary form—that is, in
machine language. Writing a machine language program, however, would be an extremely tedious, error-prone task. To
ease the process of writing computer programs, computer scientists have developed high-level programming languages
for expressing algorithms. These languages resemble English and allow the author to express algorithms in a form
that other people can understand.

A programmer typically starts by writing high-level language statements in a text editor. The programmer then
runs another program called a translator to convert the high-level program code into executable code. Because it is
possible for a programmer to make grammatical mistakes even when writing high-level code, the translator checks
for syntax errors before it completes the translation process. If it detects any of these errors, the translator alerts the
programmer via error messages. The programmer then has to revise the program. If the translation process succeeds
without a syntax error, the program can be executed by the run-time system. The run-time system might execute the
program directly on the hardware or run yet another program called an interpreter or virtual machine to execute the
program. Figure 1-3 shows the steps and software used in the coding process.

Figure 1-3 Software used in the coding process


Syntax error messages
Text editor Translator

Create high-level
language program

Run-time Other error messages


User inputs system

Program
outputs

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.3 A Not-So-Brief History of Computing Systems 7

Exercise 1-2

1. List two examples of input devices and two examples of output devices.

2. What does the central processing unit (CPU) do?

3. How is information represented in hardware memory?

4. What is the difference between a terminal-based interface and a graphical user interface (GUI)?

5. What role do translators play in the programming process?

1.3 A Not-So-Brief History of Computing Systems


Now that you have in mind some of the basic ideas of computing and computer systems, let’s take a moment to
examine how they have taken shape in history. Figure 1-4 summarizes some of the major developments in the history
of computing. The discussion that follows provides more details about these developments.

Figure 1-4 Summary of major developments in the history of computing


Approximate Dates Major Developments
Before 1800 • Mathematicians discover and use algorithms
• Abacus used as a calculating aid
• First mechanical calculators built by Pascal and Leibniz
Nineteenth century • Jacquard’s loom
• Babbage’s Analytical Engine
• Boole’s system of logic
• Hollerith’s punch-card machine
1930s • Turing publishes results on computability
• Shannon’s theory of information and digital switching
1940s • First electronic digital computers
1950s • First symbolic programming languages
• Transistors make computers smaller, faster, more durable, and less expensive
• Emergence of data-processing applications
1960–1975 • Integrated circuits accelerate the miniaturization of hardware
• First minicomputers
• Time-sharing operating systems
• Interactive user interfaces with keyboard and monitor
• Proliferation of high-level programming languages
• Emergence of a software industry and the academic study of computer science
(continues)

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
8 Chapter 1 Introduction

Figure 1-4 Summary of major developments in the history of computing (continued)


Approximate Dates Major Developments
1975–1990 • First microcomputers and mass-produced personal computers
• GUIs become widespread
• Networks and the Internet
1990–2000 • Optical storage for multimedia applications, images, sound, and video
• World Wide Web, web applications, and e-commerce
• Laptops
2000–present • Wireless computing, smartphones, and mobile applications
• Computers embedded and networked in an enormous variety of cars, household
appliances, and industrial equipment
• Social networking and use of big data in finance and commerce
• Digital streaming of music and video

Before Electronic Digital Computers


Ancient mathematicians developed the first algorithms. The word algorithm comes from the name of a Persian
mathematician, Muhammad ibn Musa al-Khwarizmi, who wrote several mathematics textbooks in the ninth century.
About 2300 years ago, the Greek mathematician Euclid, the inventor of geometry, developed an algorithm for computing
the greatest common divisor of two numbers.

A device known as the abacus also appeared in ancient times. The abacus helped people perform simple arithmetic.
Users calculated sums and differences by sliding beads on a grid of wires (see Figure 1-5a). The configuration of beads
on the abacus served as the data.

In the seventeenth century, the French mathematician Blaise Pascal (1623–1662) built one of the first mechanical
devices to automate the process of addition (see Figure 1-5b). The addition operation was embedded in the configuration
of gears within the machine. The user entered the two numbers to be added by rotating some wheels. The sum or output
number appeared on another rotating wheel. The German mathematician Gottfried Wilhelm Leibniz (1646–1716) built
another mechanical calculator that included other arithmetic functions such as multiplication. Leibniz, who invented
calculus concurrently with Newton, went on to propose the idea of computing with symbols as one of our most basic
intellectual activities. He argued for a universal language in which one could solve any problem by calculating.

Early in the nineteenth century, the French engineer Joseph-Marie Jacquard (1752–1834) designed and constructed
a machine that automated the process of weaving (see Figure 1-5c). Until then, each row in a weaving pattern had to
be set up by hand, a quite tedious, error-prone process. Jacquard’s loom was designed to accept input in the form of
a set of punched cards. Each card described a row in a pattern of cloth. Although it was still an entirely mechanical
device, Jacquard’s loom possessed something that previous devices had lacked—the ability to execute an algorithm
automatically. The set of cards expressed the algorithm or set of instructions that controlled the behavior of the
loom. If the loom operator wanted to produce a different pattern, he just had to run the machine with a different
set of cards.

The British mathematician Charles Babbage (1792–1871) took the concept of a programmable computer a step
further by designing a model of a machine that, conceptually, bore a striking resemblance to a modern general-
purpose computer. Babbage conceived his machine, which he called the Analytical Engine, as a mechanical device.
His design called for four functional parts: a mill to perform arithmetic operations, a store to hold data and a program,
an operator to run the instructions from punched cards, and an output to produce the results on punched cards.
Sadly, Babbage’s computer was never built. The project perished for lack of funds near the time when Babbage
himself passed away.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.3 A Not-So-Brief History of Computing Systems 9

Figure 1-5 Some early computing devices

ChewHow/Shutterstock.com
(a) Abacus

Archivist/Adobe Stock Photos

Nastasic/Getty Images
(b) Pascal’s Calculator (c) Jacquard’s Loom

In the last two decades of the nineteenth century, a U.S. Census Bureau statistician named Herman Hollerith
(1860–1929) developed a machine that automated data processing for the U.S. Census. Hollerith’s machine, which
had the same component parts as Babbage’s Analytical Engine, simply accepted a set of punched cards as input and
then tallied and sorted the cards. His machine greatly shortened the time it took to produce statistical results on the
U.S. population. Government and business organizations seeking to automate their data processing quickly adopted
Hollerith’s punched card machines. Hollerith was also one of the founders of a company that eventually became
International Business Machines (IBM).

Also in the nineteenth century, the British secondary school teacher George Boole (1815–1864) developed a system
of logic. This system consisted of a pair of values, TRUE and FALSE, and a set of three primitive operations on these
values, AND, OR, and NOT. Boolean logic eventually became the basis for designing the electronic circuitry to process
binary information.

A half century later, in the 1930s, the British mathematician Alan Turing (1912–1954) explored the theoretical
foundations and limits of algorithms and computation. Turing’s essential contributions were to develop the concept
of a universal machine that could be specialized to solve any computable problems and to demonstrate that some
problems are unsolvable by computers.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
10 Chapter 1 Introduction

Human Beings as Computers (1940–1945)


The needs of the combatants in World War II expanded the practical applications of computing. Two significant
examples were cryptanalysis, or the cracking of encoded messages, and the calculation of ballistics for artillery and
bombing missions. The calculation of ballistics involved the creation and manipulation of complex tables of numerical
information, while cryptanalysis required the discernment of significant patterns in chunks of text. Because machines
were not yet available to automate these tasks, they were performed manually by human beings. These people, who
numbered in the thousands, were primarily women highly skilled in mathematics and puzzle solving. They were known
at the time as “computers,” since computation is what they did. Major breakthroughs in this effort included the work
of Agnes Meyer Driscoll and Genevieve Grotjan Feinstein, who cracked major Japanese codes for the U.S. Navy.

The First Electronic Digital Computers (1940–1950)


In the late 1930s, Claude Shannon (1916–2001), a mathematician and electrical engineer at Massachusetts Institute of
Technology (MIT), wrote a classic paper titled “A Symbolic Analysis of Relay and Switching Circuits.” In this paper,
he showed how operations and information in other systems, such as arithmetic, could be reduced to Boolean logic
and then to hardware. For example, if the Boolean values TRUE and FALSE were written as the binary digits 1 and 0,
one could write a sequence of logical operations that computes the sum of two strings of binary digits. All that was
required to build an electronic digital computer was the ability to represent binary digits as on/off switches and to
represent the logical operations in other circuitry.

The needs of the combatants in World War II pushed the development of computer hardware into high gear. Several
teams of scientists and engineers in the United States, England, and Germany independently created the first generation
of general-purpose digital electronic computers during the 1940s. All of these scientists and engineers used Shannon’s
innovation of expressing binary digits and logical operations in terms of electronic switching devices. Among these
groups was a team at Harvard University under the direction of Howard Aiken. Their computer, called the Mark I,
became operational in 1944 and did mathematical work for the U.S. Navy during the war. The Mark I was considered
an electromechanical device, because it used a combination of magnets, relays, and gears to store and process data.

Another team under J. Presper Eckert and John Mauchly, at the University of Pennsylvania, produced a computer
called the Electronic Numerical Integrator and Calculator (ENIAC). The ENIAC calculated ballistics tables for the artillery
of the U.S. Army toward the end of the war. Because the ENIAC used entirely electronic components, it was almost a
thousand times faster than the Mark I.

Two other electronic digital computers were completed a bit earlier than the ENIAC. They were the Atanasoff–Berry
Computer (ABC), built by John Atanasoff and Clifford Berry at Iowa State University in 1942, and the Colossus, constructed
by a group working under Alan Turing in England in 1943. The ABC was created to solve systems of simultaneous linear
equations. Although the ABC’s function was much narrower than that of the ENIAC, the ABC is now regarded as the
first electronic digital computer. The Colossus, whose existence had been top secret until recently, was used to crack
the powerful German Enigma code during the war.

The first electronic digital computers, sometimes called mainframe computers, consisted of vacuum tubes,
wires, and plugs, and they filled entire rooms. Although they were much faster than people at computing, by current
standards they were extraordinarily slow and prone to breakdown. The early computers were also extremely difficult
to program. To enter or modify a program, a team of workers had to rearrange the connections among the vacuum
tubes by unplugging and replugging the wires. Each program was loaded by literally hardwiring it into the computer.
With thousands of wires involved, it was easy to make a mistake.

The memory of these first computers stored only data, not the program that processed the data. As we have
seen, the idea of a stored program first appeared 100 years earlier in Jacquard’s loom and in Babbage’s design for the
Analytical Engine. In 1946, John von Neumann realized that the instructions of the programs could also be stored in
binary form in an electronic digital computer’s memory. His research group at Princeton developed one of the first
modern stored-program computers.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.3 A Not-So-Brief History of Computing Systems 11

Although the size, speed, and applications of computers have changed dramatically since those early days, the
basic architecture and design of the electronic digital computer have remained remarkably stable.

The First Programming Languages (1950–1965)


The typical computer user now runs many programs, made up of millions of lines of code, that perform what would
have seemed like magical tasks 30 or 40 years ago. But the first digital electronic computers had no software as we
think of it today. The machine code for a few relatively simple and small applications had to be loaded by hand. As the
demand for larger and more complex applications grew, so did the need for tools to expedite the programming process.

In the early 1950s, computer scientists realized that a symbolic notation could be used instead of machine code,
and the first assembly languages appeared. The programmers would enter mnemonic codes for operations, such as
ADD and OUTPUT, and for data variables, such as SALARY and RATE, at a keypunch machine. The keystrokes punched
a set of holes in a small card for each instruction. The programmers then carried their stacks of cards to a system
operator, who placed them in a device called a card reader. This device translated the holes in the cards to patterns
in the computer’s memory. A program called an assembler then translated the application programs in memory to
machine code, and they were executed.

Programming in assembly language was an improvement over programming in machine code, since the symbolic
notation used in assembly languages was easier for people to read and understand. Another advantage was that the
assembler could catch some programming errors before the program was actually executed. However, the symbolic
notation still appeared a bit arcane when compared with the notations of conventional mathematics. To remedy this
problem, John Backus, a programmer working for IBM, developed FORTRAN (Formula Translation Language) in 1954.
Programmers, many of whom were mathematicians, scientists, and engineers, could now use conventional algebraic
notation. FORTRAN programmers still entered their programs on a keypunch machine, but the computer executed
them after they were translated to machine code by a compiler.

FORTRAN was considered ideal for numerical and scientific applications. However, expressing the kind of data
used in data processing—in particular, textual information—was difficult. For example, FORTRAN was not practical
for processing information that included people’s names, addresses, Social Security numbers, and the financial data
of corporations and other institutions. In the early 1960s, a team led by Rear Admiral Grace Murray Hopper developed
COBOL (Common Business Oriented Language) for data processing in the U.S. government. Banks, insurance companies,
and other institutions were quick to adopt its use in data-processing applications.

Also in the late 1950s and early 1960s, John McCarthy, a computer scientist at MIT, developed a powerful and elegant
notation called LISP (List Processing) for expressing computations. Based on a theory of recursive functions (a subject
covered in Chapter 7), LISP captured the essence of symbolic information processing. A student of McCarthy, Steve
“Slug” Russell, coded the first interpreter for LISP in 1960. The interpreter accepted LISP expressions directly as inputs,
evaluated them, and printed their results. In its early days, LISP was used primarily for laboratory experiments in an
area of research known as artificial intelligence. More recently, LISP has been touted as an ideal language for solving
any difficult or complex problems.

Although they were among the first high-level programming languages, FORTRAN and LISP have survived for decades.
They have undergone modifications to improve their capabilities and have served as models for the development of
many other programming languages. COBOL, by contrast, is no longer in active use but has survived in the form of
legacy programs that must still be maintained.

These new, high-level programming languages had one feature in common: abstraction. In science or any other
area of enquiry, an abstraction allows humans to reduce complex ideas or entities to simpler ones. For example, a set
of 10 assembly language instructions might be replaced with an equivalent algebraic expression that consists of only
five symbols in FORTRAN. Any time you can say more with less, you are using an abstraction. The use of abstraction is
also found in other areas of computing, such as hardware design and information architecture. The complexities do not
actually go away, but the abstractions hide them from view. Abstraction allows computer scientists to conceptualize,
design, and build ever more sophisticated and complex systems.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
12 Chapter 1 Introduction

Integrated Circuits, Interaction, Time-Sharing, and Software


Engineering (1965–1975)
In the late 1950s, the vacuum tube gave way to the transistor as the mechanism for implementing the electronic switches
in computer hardware. As a solid-state device, the transistor was much smaller, more reliable, more durable, and less
expensive to manufacture than a vacuum tube. Consequently, the hardware components of computers generally became
smaller in physical size, more reliable, and less expensive. The smaller and more numerous the switches became, the
faster the processing and the greater the capacity of memory to store information.

The development of the integrated circuit in the early 1960s allowed computer engineers to build ever smaller, faster,
and less-expensive computer hardware components. They perfected a process of photographically etching transistors
and other solid-state components onto very thin wafers of silicon, leaving an entire processor and memory on a single
chip. In 1965, Gordon Moore, one of the founders of the computer chip manufacturer Intel, made a prediction that came
to be known as Moore’s Law. This prediction states that the processing speed and storage capacity of hardware will
increase and its cost will decrease by approximately a factor of 2 every 18 months. This trend has held true for more
than 50 years. For example, in 1965 there were about 50 electrical components on a chip, whereas by 2000, a chip could
hold over 40 million components. Without the integrated circuit, human beings would not have gone to the moon in
1969, and we would not have the powerful and inexpensive handheld devices that we now use on a daily basis.

Minicomputers the size of a large office desk appeared in the 1960s, when the means of developing and running
programs were changing. Until then, a computer was typically located in a restricted area with a single human operator.
Programmers composed their programs on keypunch machines in another room or building. They then delivered their
stacks of cards to the computer operator, who loaded them into a card reader and compiled and ran the programs
in sequence on the computer. Programmers then returned to pick up the output results in the form of new stacks of
cards or printouts. This mode of operation, also called batch processing, might cause a programmer to wait days for
results, including error messages.

The increases in processing speed and memory capacity enabled computer scientists to develop the first time-
sharing operating system. John McCarthy, the creator of the programming language LISP, recognized that a program
could automate many of the functions performed by the human system operator. When memory, including magnetic
secondary storage, became large enough to hold several users’ programs at the same time, they could be scheduled
for concurrent processing. Each process associated with a program would run for a slice of time and then yield the
CPU to another process. All of the active processes would repeatedly cycle for a turn with the CPU until they finished.

Several users could now run their own programs simultaneously by entering commands at separate terminals
connected to a single computer. As processor speeds continued to increase, each user gained the illusion that a time-
sharing computer system belonged entirely to them.

By the late 1960s, programmers could enter program input at a terminal and also see program output immediately displayed
on a cathode ray tube (CRT) screen. Compared to its predecessors, this new computer system was both highly interactive
and much more accessible to its users. Interactive, multiuser computer systems could now support the development of
large, complex software applications by teams of programmers. One such group, under the direction of Margaret Hamilton,
constructed the programs that controlled the command and lunar landing modules for the Apollo Space Mission. She
coined the term software engineering to refer to the construction of large software systems using a disciplined method
of requirements analysis, design, coding, and testing that involves the coordination of a team of specialized developers.

Many relatively small- and medium-sized institutions, such as universities, were now able to afford computers.
These machines were used not only for data processing and engineering applications but also for teaching and research
in the new and rapidly growing field of computer science.

Personal Computing and Networks (1975–1990)


In the mid-1960s, Douglas Engelbart, a computer scientist working at the Stanford Research Institute (SRI), first saw
one of the ultimate implications of Moore’s Law: Eventually, perhaps within a generation, hardware components would
become small enough and affordable enough to mass produce an individual computer for every person. What form

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.3 A Not-So-Brief History of Computing Systems 13

would these personal computers take, and how would their owners use them? Two decades earlier, in 1945, Engelbart
had read an article in The Atlantic Monthly titled “As We May Think” that had posed this question and offered some
answers. The author, Vannevar Bush, a scientist at MIT, predicted that computing devices would serve as repositories
of information and, ultimately, of all human knowledge. Owners of computing devices would consult this information
by browsing through it with pointing devices, and they would contribute information to the knowledge base almost at
will. Engelbart agreed that the primary purpose of the personal computer would be to augment the human intellect,
and he spent the rest of his career designing computer systems that would accomplish this goal.

During the late 1960s, Engelbart built the first pointing device, or mouse. He also designed software to represent
windows, icons, and pull-down menus on a bit-mapped display screen. He demonstrated that a computer user could
not only enter text at the keyboard but could also directly manipulate the icons that represent files, folders, and
computer applications on the screen.

But for Engelbart, personal computing did not mean computing in isolation. He participated in the first experiment
to connect computers in a network, and he believed that soon people would use computers to communicate, share
information, and collaborate on team projects.

Engelbart developed his first experimental system, which he called NLS (oNLine System) Augment, on a minicomputer
at SRI. In the early 1970s, he moved to Xerox Palo Alto Research Center (PARC) and worked with a team under Alan
Kay to develop the first desktop computer system. Called the Alto, this system had many of the features of Engelbart’s
Augment, as well as email and a functioning hypertext (a forerunner of the World Wide Web). Kay’s group also developed
a programming language called Smalltalk, which was designed to create programs for the new computer and to teach
programming to children. Kay’s goal was to develop a personal computer the size of a large notebook, which he called
the Dynabook. Unfortunately for Xerox, the company’s management had more interest in photocopy machines than
in the work of Kay’s visionary research group. However, a young entrepreneur named Steve Jobs visited the Xerox lab
and saw the Alto in action. Almost a decade later, in 1984, Apple Computer, the now-famous company founded by Steve
Jobs, brought forth the Macintosh, the first successful mass-produced personal computer with a GUI.

While Kay’s group was busy building the computer system of the future in their research lab, dozens of hobbyists
gathered near San Francisco to found the Homebrew Computer Club, the first personal computer users group. They
met to share ideas, programs, hardware, and applications for personal computing. The first mass-produced personal
computer, the Altair, appeared in 1975. The Altair contained Intel’s 8080 processor, the first microprocessor chip. But
from the outside, the Altair looked and behaved more like a miniature version of the early computers than the Alto.
Programs and their input had to be entered by flipping switches, and output was displayed by a set of lights. However,
the Altair was small enough for personal computing enthusiasts to carry home, and input/output devices eventually
were invented to support the processing of text and sound.

The Osborne and the Kaypro were among the first mass-produced interactive personal computers. They boasted
tiny display screens and keyboards, with floppy disk drives for loading system software, applications software, and
users’ data files. Early personal computing applications were word processors, spreadsheets, and games such as Pac-
Man and Spacewar! These computers also ran CP/M (Control Program for Microcomputers), the first personal computer
(PC)–based operating system.

In the early 1980s a college dropout named Bill Gates and his partner Paul Allen built their own operating system
software, which they called Microsoft Disk Operating System (MS-DOS). They then arranged a deal with the giant
computer manufacturer IBM to supply MS-DOS for the new line of PCs that the company intended to mass produce.
This deal proved to be a very advantageous one for Gates’s company, Microsoft. Not only did Microsoft receive a fee
for each computer sold, it also got a head start on supplying applications software that would run on its operating
system. Fast, high sales of the IBM PC and its clones to individuals and institutions quickly made MS-DOS the world’s
most widely used operating system. Within a few years, Gates and Allen had become billionaires, and within a decade,
Gates had become the world’s richest man, a position he held for 13 straight years.

Also in the 1970s, the U.S. government began to support the development of a network that would connect computers
at military installations and research universities. The first such network, called Advanced Research Projects Agency
Network (ARPANET), connected four computers at SRI, University of California at Los Angeles (UCLA), University of
California Santa Barbara, and the University of Utah. Bob Metcalfe, a researcher associated with Kay’s group at Xerox,

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
14 Chapter 1 Introduction

developed a software protocol called Ethernet for operating a network of computers. Ethernet allowed computers to
communicate in a local area network (LAN) within an organization and also with computers in other organizations via
a wide area network (WAN). By the mid-1980s, the ARPANET had grown into what we now call the Internet, connecting
computers owned by large institutions, small organizations, and individuals all over the world.

Consultation, Communication, and E-Commerce (1990–2000)


In the 1990s, computer hardware costs continued to plummet, and processing speed and memory capacity skyrocketed.
Optical storage media, such as CDs and DVDs, were developed for mass storage. The digitizing and computational
processing of images, sound, and video became feasible and widespread. By the end of the decade, entire movies were
being shot or constructed and played back using digital devices. Toy Story, the first full-length animated feature film
produced entirely by a computer, appeared in 1995. The capacity to create lifelike three-dimensional animations of
whole environments led to a new technology called virtual reality. New devices appeared, such as flatbed scanners and
digital cameras, which could be used along with the more traditional microphone and speakers to support the input,
digitizing, and output of almost any type of information.

Desktop and laptop computers now not only performed useful work but also gave their users new means of personal
expression. This decade saw the rise of computers as communication tools, with email, instant messaging, bulletin
boards, chat rooms, and the World Wide Web.

Perhaps the most interesting story from this period concerns Tim Berners-Lee, the creator of the World Wide Web.
In the late 1980s, Berners-Lee, a theoretical physicist doing research at the CERN Institute in Geneva, Switzerland, began
to develop some ideas for using computers to share information. Computer engineers had been linking computers to
networks for several years, and it was already common in research communities to exchange files and send and receive
email around the world. However, the vast differences in hardware, operating systems, file formats, and applications
still made it difficult for users who were not adept at programming to access and share this information. Berners-Lee
was interested in creating a common medium for sharing information that would be easy to use, not only for scientists
but also for any other person capable of manipulating a keyboard and mouse and viewing the information on a monitor.

Berners-Lee was familiar with Vannevar Bush’s vision of a web-like consultation system, Engelbart’s work on NLS
Augment, and also with the first widely available hypertext systems. One of these systems, Apple Computer’s HyperCard,
broadened the scope of hypertext to hypermedia. HyperCard allowed authors to organize not just text but also images,
sound, video, and executable applications into webs of linked information. However, a HyperCard database sat only
on standalone computers; the links could not carry HyperCard data from one computer to another. Furthermore, the
supporting software ran only on Apple’s computers.

Berners-Lee realized that networks could extend the reach of a hypermedia system to any computers connected
to the net, making their information available worldwide. To preserve its independence from particular operating
systems, the new medium would need to have universal standards for distributing and presenting the information.
To ensure this neutrality and independence, no private corporation or individual government could own the medium
and dictate the standards.

Berners-Lee built the software for this new medium, which we now call the World Wide Web, in 1992. The software
used many of the existing mechanisms for transmitting information over the Internet. People contribute information
to the web by publishing files on computers known as web servers. The web server software on these computers is
responsible for answering requests for viewing the information stored on the web server. To view information on the
web, people use software called a web browser. In response to a user’s commands, a web browser sends a request for
information across the Internet to the appropriate web server. The server responds by sending the information back
to the browser’s computer, called a web client, where it is displayed or rendered in the browser.

Although Berners-Lee wrote the first web server and web browser software, he made two other even more important
contributions. First, he designed a set of rules, called Hypertext Transfer Protocol (HTTP), which allows any server
and browser to talk to each other. Second, he designed a language, Hypertext Markup Language (HTML), which allows
browsers to structure the information to be displayed on web pages. He then made all of these resources available to
anyone for free.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.3 A Not-So-Brief History of Computing Systems 15

Berners-Lee’s invention and gift of this universal information medium is a truly remarkable achievement. Today
there are millions of web servers in operation around the world. Anyone with the appropriate training and resources—
companies, government, nonprofit organizations, and private individuals—can start up a new web server or obtain
space on one. Web browser software now runs not only on desktop and laptop computers but also on handheld devices
such as cell phones.

The growth of the Internet, the web, and related software technologies also transformed manufacturing, retail sales,
and finance in the latter half of this decade. Computer-supported automation dramatically increased productivity, while
eliminating high-paying jobs for many people. Firms established and refined the chains of production and distribution
of goods, from raw materials to finished products to retail sales, which were increasingly cost-effective and global in
scope. Computer technology facilitated in large part the spread of giant big-box stores like Walmart and the rise of
online stores like Amazon, while driving many local retailers out of business and creating a workforce of part-timers
without benefits.

The technology that made online stores pervasive, called web applications, presented a revolution in the way in
which software services were delivered to people. Instead of purchasing and running software for specific applications
to run on one’s own computer, one could obtain access to a specific service through a web browser. The web application
providing this service ran on a remote computer or server located at the provider’s place of business. The web browser
played the role of the client, front end, or user interface for millions of users to access the same server application for
a given service. Client/server applications had already been in use for email, bulletin boards, and chat rooms on the
Internet, so this technology was simply deployed on the web when it became available.

The final major development of this decade took place in a computer lab at Stanford University, where two graduate
students, Sergey Brin and Larry Page, developed algorithms for indexing and searching the web. The outcome of their
work added a new verb to the dictionary: to google. Today, much of the world’s economy and research relies upon
Google’s various search platforms.

Mobile Applications and Ubiquitous Computing (2000–present)


As the previous millennium drew to a close, computer hardware continued to shrink in size and cost and to provide more
memory and greater processing speed. Laptop computers became smaller, faster, and more affordable to millions of
people. The first handheld computing devices, called personal digital assistants (PDAs), began to appear. Applications
for these devices were limited to simple video games, address books, to-do lists, and note taking, and they had to be
connected via cable to a laptop or desktop computer to transfer information.

Meanwhile, cellular technology became widespread, with millions of people beginning to use the first cell phones.
These devices, which allowed calls to be made from a simple mechanical keypad, were “dumb” compared to today’s
smartphones. But cellular technology provided the basis for what was soon to come. At about the same time, wireless
technology began to allow computers to communicate through the air to a base station with an Internet connection.
The conditions for mobile and ubiquitous computing were now in place, awaiting only the kinds of devices and apps
that would make them useful and popular.

No one foresaw the types of devices and applications that mobile computing would make possible better
than Steve Jobs (the founder of Apple Computer, mentioned earlier). During the final dozen years of his life, Jobs
brought forward from Apple several devices and technologies that revolutionized not only computing but also
the way in which people engaged in cultural pursuits. The devices were the iPod, which began as a digital music
player but evolved into a handheld general-purpose computing device; the iPhone, which added cellular phone
technology to the iPod’s capabilities; and the iPad, which realized Alan Kay’s dreams of a personal notebook
computer. All of these devices utilized touchscreen and voice recognition technology, which eliminated the need
for bulky mechanical keypads.

The associated software technologies came in the form of Apple’s iLife suite, a set of applications that allowed
users to organize various types of media (music, photos, video, and books); and Apple’s iTunes, iBooks, and App
Stores, vendor sites that allowed developers to market mobile media and applications. The web browser that for a
decade had given users access to web apps became just another type of app in the larger world of mobile computing.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
16 Chapter 1 Introduction

The new millennium has seen another major addition to the digital landscape: social networking applications.
Although various Internet forums, such as chatrooms and bulletin board systems, had been in use for a couple of
decades, their use was not widespread. In 2004, Mark Zuckerberg, a student at Harvard University, changed all that
when he launched Facebook from his college dorm room. The application allowed students to join a network to share
their profiles; post messages, photos, and videos; and generally communicate as “friends.” Participation in this network
rapidly spread to include more than a billion users. Social networking technology now includes many other variations,
as exemplified by LinkedIn, Twitter, Tumblr, Flickr, and Instagram.

During the past decade (2010–2020), as computing applications have migrated from standalone desktop machines
to mobile devices, the storage of data has moved from individual devices to giant server farms to which these devices
are wirelessly connected. Our data, including music, photos, text, financial assets, and geolocation, are now located
in a digital cloud, which we can access from our phones, watches, TV sets, and automobiles, among other things.
Cloud computing and wireless technology also underlie an even broader Internet of Things (IOT), in which practically any
physical objects (including my cat) containing the appropriate computer chips can send and receive digital information.

We conclude this not-so-brief overview by mentioning the rise of a technology known as big data. Governments,
businesses, and hackers continually monitor Internet traffic for various purposes. This “clickstream” can be “mined”
to learn users’ preferences, interests, and behavior patterns to better serve them, exploit them, or spy on them. For
example, an online store might advertise a product on a person’s Facebook page immediately after that person viewed
a similar product while shopping online or mentioned the product in the presence of a virtual assistant such as Alexa.
Researchers in the field of data science have created algorithms that process massive amounts of data to discover
trends and predict outcomes.

To summarize this history, one trend ties the last several decades of computing together: rapid technical progress.
Processes and the things in which they are embedded have become automated, programmable, smaller, faster, highly
interconnected, and easily visualized and interpreted.

If you want to learn more about the history of computing, consult the sources listed in Appendix E. We now turn
to an introduction to programming in Python.

1.4 Getting Started with Python Programming


Guido van Rossum invented the Python programming language in the early 1990s. Python is a high-level, general-purpose
programming language for solving problems on modern computer systems. The language and many supporting tools
are free, and Python programs can run on any operating system. You can download Python, its documentation, and
related materials from www.python.org. Instructions for downloading and installing Python are in Appendix A. In this
section, we show you how to create and run simple Python programs.

Running Code in the Interactive Shell


Python is an interpreted language, and you can run simple Python expressions and statements in an interactive
programming environment called the shell. The easiest way to open a Python shell is to launch the Integrated DeveLopment
Environment (IDLE). This is an integrated program development environment that comes with the Python installation.
When you do this, a window named Python Shell opens. Figure 1-6 shows a shell window on macOS. A shell window
running on a Windows system or a Linux system should look similar, if not identical, to this one. Note that the version of

Figure 1-6 Python shell window

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.4 Getting Started with Python Programming 17

Python appearing in this screenshot is 3.10.4. This book assumes that you will use Python 3 rather than Python 2. There
are substantial differences between the two versions, and many examples used in this book will not work with Python 2.
A shell window contains an opening message followed by the special symbol >>>, called a shell prompt. The cursor at
the shell prompt waits for you to enter a Python command. Note that you can get immediate help by entering help at
the shell prompt or selecting help from the window’s drop-down menu.
When you enter an expression or a statement, Python evaluates it and displays its result, if there is one, followed
by a new prompt. The next few lines show the evaluation of several expressions and statements.

>>> 3 + 4 # Simple arithmetic


7
>>> 3 # The value of 3 is
3
>>> "Python is really cool!" # Use a string for text
'Python is really cool!'
>>> name = "Ken Lambert" # Give a variable a value
>>> name # The value of name is
'Ken Lambert'
>>> "Hi there, " + name # Create some new text
'Hi there, Ken Lambert'
>>> print('Hi there') # Output some text
Hi there
>>> print("Hi there,", name) # Output two values
Hi there, Ken Lambert

Note the use of colors in the Python code. The IDLE programming environment uses color-coding to help the reader
pick out different elements in the code. In this example, the items within quotation marks are in green, the names of
standard functions are in purple, program comments are in red, and the responses of IDLE to user commands are in
blue. The remaining code is in black. Table 1-1 lists the color-coding scheme used in all program code in this book.

Table 1-1 Color-Coding of Python program elements in IDLE


Color Type of Element Examples
Black Inputs in the IDLE shell 67, +, name, y = factorial(x)
Numbers
Operator symbols
Variable, function, and method references
Punctuation marks
Blue Outputs in the IDLE shell 'Ken Lambert'
Function, class, and method names in definitions def factorial(n)
Green Strings "Ken Lambert", 'a'
Orange Keywords def, if, while
Purple Built-in function names abs, round, int
Red Program comments # Output the results
Error messages in the IDLE shell ZeroDivisionError: division by zero

The Python shell is useful for experimenting with short expressions or statements to learn new features of the
language, as well as for consulting documentation on the language. To quit the Python shell, you can either select the
window’s close box or press the CTRL-D key combination.

The means of developing more complex and interesting programs are examined in the rest of this section.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
18 Chapter 1 Introduction

Input, Processing, and Output


Most useful programs accept inputs from some source, process these inputs, and then finally output results to some
destination. In terminal-based interactive programs, the input source is the keyboard, and the output destination is
the terminal display. The Python shell itself is such a program; its inputs are Python expressions or statements. Its
processing evaluates these items. Its outputs are the results displayed in the shell.

The programmer can also force the output of a value by using the print function. The simplest form for using
this function looks like the following:

print(<expression>)

This example shows you the basic syntax (or grammatical rule) for using the print function. The angle brackets
(the < and > symbols) enclose a type of phrase. In actual Python code, you would replace this syntactic form, including
the angle brackets, with an example of that type of phrase. In this case, <expression> is shorthand for any Python
expression, such as 3 + 4.

When running the print function, Python first evaluates the expression and then displays its value. In the example
shown earlier, print was used to display some text. The following is another example:

>>> print("Hi there")


Hi there

In this example, the text "Hi there" is the text that we want Python to display. In programming terminology,
this piece of text is referred to as a string. In Python code, a string is always enclosed in quotation marks. However,
the print function displays a string without the quotation marks.

You can also write a print function that includes two or more expressions separated by commas. In such a case,
the print function evaluates the expressions and displays their results, separated by single spaces, on one line. The
syntax for a print statement with two or more expressions looks like the following:

print(<expression>,…, <expression>)

Note the ellipsis (…) in this syntax example. The ellipsis indicates that you could include multiple expressions
after the first one. Whether it outputs one or multiple expressions, the print function always ends its output with a
newline. In other words, it displays the values of the expressions, and then it moves the cursor to the next line on the
console window.

To begin the next output on the same line as the previous one, you can place the expression end = "", which
says “end the line with an empty string instead of a newline,” at the end of the list of expressions, as follows:

print(<expression>, end = "")

As you create programs in Python, you’ll often want your programs to ask the user for input. You can do this by
using the input function. This function causes the program to stop and wait for the user to enter a value from the
keyboard. When the user presses Return or Enter key, the function accepts the input value and makes it available to
the program. A program that receives an input value in this manner typically saves it for further processing.

The following example receives an input string from the user and saves it for further processing. The user’s input
is in italics.

>>> name = input("Enter your name: ")


Enter your name: Ken Lambert
>>> name
'Ken Lambert'
>>> print(name)
Ken Lambert
>>>

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.4 Getting Started with Python Programming 19

The input function does the following:

1. Displays a prompt for the input. In this example, the prompt is "Enter your name: ".
2. Receives a string of keystrokes, called characters, entered at the keyboard and returns the string to the
shell.

How does the input function know what to use as the prompt? The text in parentheses, "Enter your name: ",
is an argument for the input function that tells it what to use for the prompt. An argument is a piece of information
that a function needs to do its work.

The string returned by the function in our example is saved by assigning it to the variable name. The form of an
assignment statement with the input function is the following:

<variable identifier> = input(<a string prompt>)

A variable identifier, or variable for short, is just a name for a value. When a variable receives its value in an input
statement, the variable then refers to this value. If the user enters the name "Ken Lambert" in our last example, the
value of the variable name can be viewed as follows:

>>> name
'Ken Lambert'

The input function always builds a string from the user’s keystrokes and returns it to the program. After inputting
strings that represent numbers, the programmer must convert them from strings to the appropriate numeric types. In
Python, there are two type conversion functions for this purpose, called int (for integers) and float (for floating-
point numbers). The next session inputs two integers and displays their sum:

>>> first = int(input("Enter the first number: "))


Enter the first number: 23
>>> second = int(input("Enter the second number: "))
Enter the second number: 44
>>> print("The sum is", first + second)
The sum is 67

Note that the int function is called with each result returned by the input function. The two numbers are added,
and then their sum is output. Table 1-2 summarizes the functions introduced in this subsection.

Table 1-2 Basic Python functions for input and output


Function What it Does
float(<a string of digits>) Converts a string of digits to a floating-point value
int(<a string of digits>) Converts a string of digits to an integer value
input(<a string prompt>) Displays the string prompt and waits for keyboard input;
returns the string of characters entered by the user
print(<expression>, ...,<expression>) Evaluates the expressions and displays them, separated by
one space, in the console window
<string 1> + <string 2> Glues the two strings together and returns the result

Editing, Saving, and Running a Script


While it is easy to try out short Python expressions and statements interactively at a shell prompt, it is more convenient
to compose, edit, and save longer, more complex programs in files. We can then run these program files or scripts either
within IDLE or from the operating system’s command prompt without opening IDLE. Script files are also the means by

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
20 Chapter 1 Introduction

which Python programs are distributed to others. Most important, as you know from writing term papers, files allow
you to save, safely and permanently, many hours of work.

To compose and execute programs in this manner, you perform the following steps:

1. Select the option New File from the File menu of the shell window.
2. In the new window, enter Python expressions or statements on separate lines, in the order in which you
want Python to execute them.

3. At any point, you may save the file by selecting File/Save. If you do this, you should use a .py extension. For
example, your first program file might be named myprogram.py.

4. To run this file of code as a Python script, select Run Module from the Run menu or press the F5 key.

The command in Step 4 reads the code from the saved file and executes it. If Python executes any print functions
in the code, you will see the outputs as usual in the shell window. If the code requests any inputs, the interpreter will
pause to allow you to enter them. Otherwise, program execution continues invisibly behind the scenes. When the
interpreter has finished executing the last instruction, it quits and returns you to the shell prompt.

Figure 1-7 shows an IDLE window containing a complete script that prompts the user for the width and height of
a rectangle, computes its area, and outputs the result:

Figure 1-7 Python script in an IDLE window


Python™

When the script is run from the IDLE window, it produces the interaction with the user in the shell window shown
in Figure 1-8.

Figure 1-8 Interaction with a script in a shell window

Python™

This can be a slightly less interactive way of executing programs than entering them directly at Python’s interpreter
prompt. However, running the script from the IDLE window will allow you to construct some complex programs, test
them, and save them in program libraries that you can reuse or share with others.

Behind the Scenes: How Python Works


Whether you are running Python code as a script or interactively in a shell, the Python interpreter does a great deal of
work to carry out the instructions in your program. This work can be broken into a series of steps, as shown in Figure 1-9.

1. The interpreter reads a Python expression or statement, also called the source code, and verifies that it is
well formed. In this step, the interpreter behaves like a strict English teacher who rejects any sentence that

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.4 Getting Started with Python Programming 21

Figure 1-9 Steps in interpreting a Python program


Python code Syntax Checker Syntax error messages
and Translator

Byte code

User inputs Python Virtual Other error messages


Machine (PVM)

Program
outputs

does not adhere to the grammar rules, or syntax, of the language. As soon as the interpreter encounters
such an error, it halts translation with an error message.
2. If a Python expression is well formed, the interpreter then translates it to an equivalent form in a low-level
language called byte code. When the interpreter runs a script, it completely translates it to byte code.

3. This byte code is next sent to another software component, called the Python virtual machine (PVM), where
it is executed. If another error occurs during this step, execution also halts with an error message.

Exercise 1-3

1. Describe what happens when the programmer enters the string “Greetings!” in the Python shell.

2. Write a line of code that prompts the user for his or her name and saves the user’s input in a variable
called name.

3. What is a Python script?


4. Explain what goes on behind the scenes when your computer runs a Python program.

Detecting and Correcting Syntax Errors


Programmers inevitably make typographical errors when editing programs, and the Python interpreter will nearly
always detect them. Such errors are called syntax errors. The term syntax refers to the rules for forming sentences
in a language. When Python encounters a syntax error in a program, it halts execution with an error message. The
following sessions with the Python shell show several types of syntax errors and the corresponding error messages:

>>> length = int(input("Enter the length: "))


Enter the length: 44
>>> print(lenth)
Traceback (most recent call last):
File "<pyshell#l>", line 1, in <module>
NameError: name 'lenth' is not defined

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
22 Chapter 1 Introduction

The first statement assigns an input value to the variable length. The next statement attempts to print the value
of the variable lenth. Python responds that this name is not defined. Although the programmer might have meant to
write the variable length, Python can read only what the programmer actually entered. This is a good example of the
rule that a computer can read only the instructions it receives, not the instructions we intend to give it.

The next statement attempts to print the value of the correctly spelled variable. However, Python still generates
an error message.

>>> print(length)
SyntaxError: unexpected indent

In this error message, Python explains that this line of code is unexpectedly indented. In fact, there is an extra
space before the word print. Indentation is significant in Python code. Each line of code entered at a shell prompt or
in a script must begin in the leftmost column, with no leading spaces. The only exception to this rule occurs in control
statements and definitions, where nested statements must be indented one or more spaces.

You might think that it would be painful to keep track of indentation in a program. However, the Python language
is much simpler than other programming languages. Consequently, there are fewer types of syntax errors to encounter
and correct, and a lot less syntax for you to learn!

In our final example, the programmer attempts to add two numbers but forgets to include the second one:

>>> 3 +
SyntaxError: invalid syntax

In later chapters, you will learn more about other kinds of program errors and how to repair the code that generates
them.

Summary
• One of the most fundamental ideas of computer science is the algorithm. An algorithm is a sequence of
instructions for solving a problem. A computing agent can carry out these instructions to solve a problem in a
finite amount of time.

• Another fundamental idea of computer science is information processing. Practically any relationship among real-
world objects can be represented as information or data. Computing agents manipulate information and transform
it by following the steps described in algorithms.

• Real computing agents can be constructed out of hardware devices. These consist of a CPU, memory, and input
and output devices. The CPU contains circuitry that executes the instructions described by algorithms. The
memory contains switches that represent binary digits. All information stored in memory is represented in binary
form. Input devices such as a keyboard and flatbed scanner and output devices such as a monitor and speakers
transmit information between the computer’s memory and the external world. These devices also transfer
information between a binary form and a form that human beings can use.

• Some real computers, such as those in fitness trackers and home thermostats, are specialized for a small set of
tasks, whereas a desktop or laptop computer is a general-purpose problem-solving machine.

• Software provides the means whereby different algorithms can be run on a general-purpose hardware device.
The term software can refer to editors and interpreters for developing programs; an operating system for
managing hardware devices; user interfaces for communicating with human users; and applications such as word
processors, spreadsheets, database managers, games, and media-processing programs.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Key Terms 23

• Software is written in programming languages. Languages such as Python are high level; they resemble English
and allow authors to express their algorithms clearly to other people. A program called an interpreter translates a
Python program to a lower-level form that can be executed on a real computer.

• The Python shell provides a command prompt for evaluating and viewing the results of Python expressions and
statements. IDLE is an integrated development environment that allows the programmer to save programs in files
and load them into a shell for testing.

• Python scripts are programs that are saved in files and run from a terminal command prompt. An interactive
script consists of a set of input statements, statements that process these inputs, and statements that output the
results.

• When a Python program is executed, it is translated into byte code. This byte code is then sent to the PVM for
further interpretation and execution.

• Syntax is the set of rules for forming correct expressions and statements in a programming language. When
the interpreter encounters a syntax error in a Python program, it halts execution with an error message. Two
examples of syntax errors are a reference to a variable that does not yet have a value and an indentation that is
unexpected.

Key Terms
abacus data networks
abstraction data science newline
algorithm digital cloud operating system
applications software executed optical storage media
argument file system output
artificial intelligence graphical user interface (GUI) personal digital assistants (PDAs)
assembler hardware ports
assembly languages high-level programming languages primary memory
batch processing hypermedia processor
big data information processing programs
binary digits input programming languages
bits input/output devices program libraries
bit-mapped display screen integrated circuit Python Shell
byte code Internet of Things (IOT) Python virtual machine (PVM)
card reader interpreter random access memory (RAM)
cathode ray tube (CRT) screen keypunch machine run-time system
central processing unit (CPU) loader secondary memory
client machine code semiconductor storage media
client/server applications magnetic storage media server
cloud computing mainframe computers server farms
compiler memory shell
computing agent microprocessor software
concurrent processing Moore’s Law software engineering

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
24 Chapter 1 Introduction

solid-state device text editor virtual assistant


source code touchscreen interface virtual machine
string transistor virtual reality
syntax translator web applications
syntax errors type conversion functions web browser
system software user interfaces web client
terminal-based interface variable identifier web servers

Review Questions
1. Which of the following is an example of an algorithm?

a. A dictionary c. A shopping list


b. A recipe d. The spelling checker of a word processor

2. Which of the following contains information?

a. An audio CD c. An automobile
b. A refrigerator d. A stereo speaker

3. Which of the following is a general-purpose computing device?

a. A cell phone c. A microwave oven


b. A portable music player d. A programmable thermostat

4. Which of the following is an input device?

a. Speaker c. Printer
b. Microphone d. Display screen

5. Which of the following are output devices?

a. A digital camera c. A flatbed scanner


b. A keyboard d. A monitor

6. What is the purpose of the CPU?

a. Store information c. Decode and execute instructions


b. Receive inputs from the human user d. Send output to the human user

7. Which of the following translates and executes instructions in a programming language?

a. A compiler c. A loader
b. A text editor d. An interpreter

8. Which of the following outputs data in a Python program?

a. The input function c. The print function


b. The assignment statement d. The main function

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Debugging Exercise 25

9. What is IDLE used to do?

a. Edit, compile, and run Python programs c. Just compile Python programs
b. Just edit Python programs d. Just run Python programs

10. What is the set of rules for forming sentences in a language called?

a. Semantics c. Syntax
b. Pragmatics d. Logic

Programming Exercises
1. Write a Python program in a file named myinfo.py that prints (displays) your name, address, and telephone
number. (LO: 1.4)

2. Open an IDLE window and enter the program from Figure 1-7 that computes the area of a rectangle. Save the
program to a file named rectangle.py and load it into the shell by pressing the F5 key and correct any errors
that occur. Test the program with different inputs by running it at least three times. (LO: 1.4)

3. Write a program in a file named triangle.py to compute the area of a triangle. Issue the appropriate prompts
for the triangle’s base and height. Then, use the formula .5 * base * height to compute the area. Test the
program from an IDLE window. (LO: 1.4)

4. Write and test a program in a file named circle.py that computes the area of a circle. This program
should request a number representing a radius as input from the user. It should use the formula
3.14 * radius ** 2 to compute the area and then output this result suitably labeled. (LO: 1.4)

5. A cuboid is a solid figure bounded by six rectangular faces. Its dimensions are its height, width, and depth.
Write a Python program in a file named cuboid.py that computes and prints the volume of a cuboid, given its
height, width, and depth as inputs. The volume is just the product of these three inputs. The output should be
labeled as “cubic units.” (LO: 1.4)

Debugging Exercise
Consider the following interaction at the Python shell:

>>> first = input("Enter the first integer: ")


Enter the first number: 23
>>> second = input("Enter the second integer: ")
Enter the second number: 44
>>> print("The sum is", first + second)
The sum of the two integers is 2344

The expected output is 67, but the output of this computation is 2344. Explain what causes this error and describe
how to correct it.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Chapter 2

Software
Development,
Data Types, and
Expressions
Learning Objectives
When you complete this chapter, you will be able to:
› 2.1 D
 escribe the basic phases of software development: analysis, design, coding,
and testing
› 2.2 Use strings for the terminal input and output of text
› 2.3 Use integers and floating-point numbers in arithmetic operations
› 2.4 Construct arithmetic expressions
› 2.5 Import functions from library modules

This chapter begins with a discussion of the software development process, followed by a case study in which
you walk through the steps of program analysis, design, coding, and testing. The chapter also examines the
basic elements that form programs. These include the data types for text and numbers and the expressions
that manipulate them. The chapter concludes with an introduction to the use of functions and modules in
simple programs.

2.1 The Software Development Process


There is much more to programming than writing lines of code, just as there is more to building houses than
pounding nails. The other aspects of programming include organization and planning, and various conventions
for diagramming those plans. Computer scientists refer to the process of planning and organizing a program
as software development. There are several approaches to software development. One version is known as
the waterfall model.

27

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
28 Chapter 2 Software Development, Data Types, and Expressions

The waterfall model consists of several phases:

1. Customer request: In this phase, the programmers receive a broad statement of a problem that is
potentially amenable to a computerized solution. This step is also called the user requirements phase.
2. Analysis: The programmers determine what the program will do. This is sometimes viewed as a process of
clarifying the specifications for the problem.
3. Design: The programmers determine how the program will do its task.
4. Implementation: The programmers write the program. This step is also called the coding phase.
5. Integration: Large programs have many parts. In the integration phase, these parts are brought together into
a smoothly functioning whole, usually not an easy task.
6. Maintenance: Programs usually have a long life; a lifespan of 5 to 15 years is common for software. During
this time, requirements change, errors are detected, and minor or major modifications are made.

The phases of the waterfall model are shown in Figure 2-1. As you can see, the figure resembles a waterfall, in
which the results of each phase flow down to the next. However, if a developer makes a mistake in an early phase, it
may require them to back up and redo some of the work. Modifications made during maintenance also require backing
up to earlier phases. Taken together, these phases are also called the software development life cycle.

Figure 2-1 The waterfall model of the software development process


Customer request

Verify

Analysis

Verify

Design

Verify

Implementation

Test

Integration

Test

Maintenance

Although the diagram depicts distinct phases, this does not mean that developers must analyze and design a
complete system before coding it. Modern software development is usually incremental and iterative. This means that
analysis and design may produce a rough draft, skeletal version, or prototype of a system for coding, and then back
up to earlier phases to fill in more details after some testing. For purposes of introducing this process, however, this
chapter treats these phases as distinct.

Programs rarely work perfectly the first time they are run, which is why they should be subjected to extensive and
careful testing. Many people think that testing is an activity that applies only to the implementation and integration
phases; however, you should scrutinize the outputs of each phase carefully. Keep in mind that mistakes found early are
much less expensive to correct than those found late. Figure 2-2 illustrates some relative costs of repairing mistakes
when found in different phases. These are not just financial costs but also costs in time and effort.

Copyright 2024 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Random documents with unrelated
content Scribd suggests to you:
penetrate. From the heavy beams under the roof, wisps
of clothes waved weird and ghostlike in the slight wind.
The two girls stood huddled together and felt like
intruders as they talked of the people who once must
have lived there. Judy, her imagination in full flight,
pointed to the tattered garments.

“Look, I can make out a miner’s cap—and there’s an old 138


bearskin coat. They probably had to shoot the bear, eat
the meat—bear meat is very good, you know—and then
use the fur to keep from freez—”

She stopped in the middle of her rhapsody. A pair of


small beady eyes looked down on her. She could
distinguish a wing—then another. It moved! more wings
—more beady eyes. Wings fluttered—began to circle
near them.

“Bats! The place is full of them. They can attack us—get


into our hair!”

Without a moment’s delay, they flung hands over their


heads and rushed to get out, stumbling over the ancient
doorsill in their hasty exit.

Once out in the sunny meadow, Lynne laughed at


herself. “I feel like a goose running out the way I did.
Who ever heard of bats attacking anyone?”

“Is that so?” Judy said warmly. “One night a few


summers back a bat got into my bedroom. It flapped
around horribly, looking for me. I still get the creeps
when I think of it. If Grandpa hadn’t come in—”

“O.K. I’ve heard of bats in the belfry,” Lynne said dryly,


“but never mind. Have it your own way.”
They walked on to examine the few remaining houses.
Except for the ruins of a fence and an upside-down hut
that was probably once an outhouse, nothing remained
to indicate that people once lived there.

“Ashcroft is sure a ghost town,” they both agreed.

They started to trudge back. They had gone further


than they expected and found the walking hard and
tiring. When they stopped once or twice to rest, they
thought they heard the unmistakable chop chop of an
ax. Following the direction of the sound, they came
upon a cabin, no larger than a good-sized woodshed.
Near it stood a man swinging his ax with an easy,
steady rhythm.

He looked up as they approached and said, in answer to 139


their greeting, “’Tis a fine morning.” He nodded and
smiled at them.

They could see at once that he was old, very old. His
face was crisscrossed with fine lines, but his blue eyes
were bright and he held himself so erect that Judy
involuntarily straightened her slumping shoulders.

“Isn’t that pretty strenuous?” Lynne asked, pointing to


the huge tree he was splitting.

He smiled again. “I’m eighty-two and never felt better.


We’ll need all the wood we can cut.” He spoke with the
pride of the very old whom the years have used well.

Judy walked closer to the cabin and the door being ajar,
she looked inside—two cots, some shelves sparsely
stacked with cans of soup, some other foodstuffs.
“You don’t live here, do you?” she asked, her voice
incredulous as she again faced the old man.

“Yes. My pal and I, we live here. We’re the only two


natives left in Ashcroft.”

“You are?” Lynne and Judy said in one voice.

“Let’s stay here for a while,” Judy whispered. “The


meadow’s so flat, we can’t help seeing Allen when he
comes looking for us.”

Lynne nodded. “May we sit here a little while and rest,


Mister? We expect to meet someone later.”

He seemed pleased. “I’m glad of your company.” He


picked up his ax and placed it against the woodpile.

“Set yourselves down. Make yourselves comfortable—


the logs or the grass.”

He sat down on the fallen tree and Judy, on the stiff


undergrowth, looked up at him with deep,
commiserating eyes.

“I don’t see how you can bear to live in that little cabin 140
all winter. I should think you’d die of lonesomeness or
freeze to death!”

“It’s never that cold, Miss. The sun’s good and hot even
on the coldest days. And I’m used to it.”

He looked at Lynne. “Came here as a boy when my


father worked in the silver mines and I’ve stayed here,
off and on, ever since.”
He fished out a pipe from his shirt pocket and the girls
watched the gnarled fingers first clean it and then stuff
it with some yellowish weed.

“Was Ashcroft ever like Aspen? You know what I mean,


well populated, with lots of mines?” Lynne asked, as the
old man puffed contentedly on his pipe.

“Well, yes and no. Ashcroft was built up before Aspen,


but Aspen got ahead faster.”

“Why?” Judy asked.

“I’ll tell yer. For one thing, the mines out this way were
hard to work and new mines weren’t easy to locate. At
Aspen things were different. New veins kept on being
opened all the time and they weren’t so hard to mine.
Nature favored it more, or maybe it was better
equipment. Anyhow, prospectors and settlers both got
discouraged. They gradually took off. Yep, they just
moved away. A lot of them dragged their houses with
them by mule team.”

“What about Montezeuma and Tam-o-shanta? They


were here. Horace Tabor made a big success of his
mines.” Judy wagged her head in the manner of one
who had spent her life in the bowels of the earth.

Lynne looked at her in surprise. “How do you know?”

“Oh, I’ve been reading up about it,” she answered with


a superior smile.

But the old man saw nothing strange in Judy’s erudition.

141
142
“The young lady’s right,” he said. “Montezeuma had
plenty of good ore and it did well. Made Tabor a tidy
fortune. But it was too high. Nearly thirteen thousand
feet. Dragging supplies out there was hard, but only a
man like Tabor could make a good thing of it.” He
nodded at them and a great smile spread over the
wrinkled face, deepening the two well-marked furrows
around his jaw.

“Tabor built a mansion out here, real elegant, gold


paper on the walls. Built it for Baby Doe. That’s the
second Mrs. Tabor that maybe you heard about.”

“Yes. Did you ever see her?” Judy asked, with mounting
interest.

“Well, in a manner of speaking. Saw her coming and


going. The day she came out to see Montezeuma, Tabor
was that happy he declared a twenty-four-hour holiday
for everyone working in the mine. He was a real silver
king.” The old man shook his head appreciatively. “He
treated everyone that day to all the liquor he could
drink.”

But his smile quickly faded. “Augusta got that mine too.”
He sat thinking for a moment. “Not that you can
altogether blame her, the first Mrs. Tabor. She’d helped
him when he was—well, nobody. And now that he was
rich and famous, she wanted to hold on. Guess she
loved him, so she said right out in all the newspapers.”

“Augusta seems to have done very well for herself,”


Judy commented sternly.

Again Lynne lifted her eyebrows. She was certain now


Judy had been boning up not only on the history but on
the gossip column of those days.

“Well, did Horace Tabor and his new love live happily
ever after?” Lynne asked lightly.
Judy brushed aside the question. “What happened after 143
the Silver Panic, Mister? Did Baby Doe leave Tabor when
he became poor?”

“No, Miss.” The answer was emphatic. “She stuck to him


through thick and thin. Nobody expected it of her—she
was that young and handsome. When she married
Tabor, the biggest people in Washington came to the
wedding. Tabor was an important man, not only rich.
He’d done a lot for Leadville—the opera house and then
at Denver, built a hotel and lots more.

“The State of Colorado was grateful and he become a


Senator for a while.” His words came more slowly as if
the embers of his excitement had died out like his pipe.

“Well, Augusta made such a scandal of his leaving her


that she spoiled his chances in politics. Then comes the
Panic—1893! Baby Doe, from being the millionaire
darling of a silver king, came down to even taking in
washing. She proved herself a good wife and faithful.”

“I knew she would,” Judy said triumphantly. She wanted


to know more. “Is that all?” she asked.

“No.” The old man shook his head gravely. “As I was
saying, Tabor lost everything and what he didn’t lose,
he’d given to Augusta. She was rich and stayed rich. All
that remained to Tabor was one mine. He still owned
Matchless. It wasn’t paying any but he had great faith in
it. When he was on his deathbed, he tells Baby Doe,
‘Hold on to Matchless. It’ll make a fortune yet.’”

“And did it?” Judy asked anxiously.

The old man shook his head. “She held on to it because


Tabor told her. She become that poor, she didn’t have a
roof over her head. So she moved out to the mine.
Lived alone in a one-room cabin.”

He leaned forward, holding his young listeners.

“Gettin’ enough to eat wasn’t all her trouble. Tax 144


collectors came out to the mine and she held them off
with a gun. But she had friends who stuck by her,
respected her grit, like that Jacob Sands of Aspen and
some others, I forget the names. They spent money to
clear her title to Matchless so that she could hold on to
it, to the very end. She held it for forty years, but it
never paid any.” He sighed deeply.

“They found her one day, her body dressed in rags, her
feet covered with newspapers to keep out the cold—
found her frozen to death.”

For a while no one spoke. Then as if wishing to break


the pall of sadness that engulfed him, Lynne asked, “Do
you ever get to Aspen?”

“Sometimes. We have friends over there,” and he


pointed in the direction of Toklat.

Looking across the field, they saw Allen coming toward


them with great long strides. “Had a wonderful time
with Mr. Mace,” he said as soon as they were within
earshot. Then coming closer he noticed the old man.
Allen’s eyes seemed to ask, “Where did you pick up this
ancient?”

“Allen,” Lynne said quickly, “this gentleman is one of the


two natives of Ashcroft—and still lives here.”

“I’m happy to know you,” Allen said, shaking his hand.


They repeated the Baby Doe story for Allen’s benefit as
they spread their lunch, which they insisted the old man
share with them. When they left, he stood there
waving, a tall spare figure, framed by the deserted
houses and the brooding mountains.

Allen hurried them along. “What an extraordinary man


Mace is! What skill he uses in handling his dogs!”

“What’s so special about that?” Judy asked, still


ruminating about the ups and downs of Baby Doe.
“Horses pull wagons and dogs pull sleighs. Why is Mr.
Mace so wonderful?”

“For one thing, kid,” Allen said, annoyed at Judy’s lack 145
of enthusiasm, “he was with the ski troops that saw
Arctic duty in World War II. He learned about dogs the
hard way.”

Allen turned to a more appreciative audience. “Lynne, I


guess none of us realized what these mountain troops
went through out in that wasteland of snow and ice.
The pilots they saved, the planes and cargo they
salvaged—”

“What had the dogs to do with the pilots?” Judy asked.

“Fierce storms often forced the planes down,” Allen


explained patiently. “Mace was in charge of a division
whose job it was to search for and rescue the flyers
and, of course, to save the air cargo on which their lives
depended. You see, Judy, only dogs and dog-sleighs can
travel over that sort of country.”

They moved along at a snail’s pace as Allen became


more and more engrossed in his subject. “Mr. Mace had
to train the dogs, keep the drivers from fighting each
other. Tempers get ugly under such conditions. The war
went on. Sleighs wore out. He had to make new ones—
new equipment.” Allen shook his head. “Mace is a
modest man. You have to drag the story out of him.”

“How did he happen to get to Ashcroft?” Lynne asked.

Allen laughed. “I asked him that myself. It seems that


when the war was over, they didn’t know what to do
with those wonderful dogs. The top brass ordered them
sold. Mace said he’d grown to love working with dogs.
The thought of giving it up made him wretched. He
saved some money and he bought all the top-strain
dogs he could afford. He and his wife decided to take
their dogs to Aspen to breed and train them, as a
hobby.”

“What did he do before the war?” Lynne asked.

“Some kind of research on flowers that grow on the 146


Rocky Mountain slopes. But when he came back, there
was no interest in that sort of thing. And there weren’t
any jobs that he could find to do around Aspen. So he
decided to move out to Ashcroft. Land was cheap and
snow lay on the mountains seven months of the year.
Dog-sledding and skiing had become a great national
sport. So he decided to turn his hobby into a job! He
and Mrs. Mace worked through one summer and a long
hard winter to build the log and stone lodge we passed.
Guests can stay there and enjoy long trips into the
mountains with the dog-sled teams and—”

Lynne, interrupting him with a laugh, said, “You’re so


wound up talking about Mr. Mace, you forgot about the
tour. I can see from here people crowding through the
gate.”
They made the remaining distance on the run. They
arrived in time to join the twenty or thirty others all
trying to squeeze as close as possible to the owner and
guide, while Judy unabashed scrutinized every likely or
unlikely person that might be Karl.

147
13
THE HUSKIES

Stuart Mace was dressed in well-fitting khaki trousers


and a plaid shirt open at the throat. His sturdy bronzed
neck suited the finely molded features of his face and
his smile was warm and friendly.

“As you see,” he began, “we have a great family of


dogs, bred for hard work in the mountains, ice and
snow. From our original nine dogs we have eighty,
among them some of the finest leaders and teams in
the country.”

He motioned the group to follow him. Individual kennels


shaded by trees extended in all directions. The dogs,
tied by long leashes, had a great deal of freedom. They
looked at the visitors unmoved. None barked. Mr. Mace
pointed out common characteristics: their large, long-
haired bodies, the markings on their bodies, their
intelligent faces, their long pointed ears and bushy tails.
As Mr. Mace passed the dogs, he fondled them and
those who were by chance overlooked snuggled up to
him and their eyes begged for his caress.

“Let’s have a look at some of the very young dogs,” Mr.


Mace said, the crowd at his heels. He picked up a
beautiful furry puppy and held him in his arms like a
baby.
“This Alaskan dog is only three months old. We know by 148
this time that she will never do the work our dog teams
must do.”

“How do I know?” Mr. Mace smiled at the man who


asked the question.

“We have our way of knowing. When I decide that such


is the case, we sell them as pets. They make good
watch dogs and are gentle and affectionate.”

“What does it cost to buy such a puppy?” Allen asked in


a low voice.

“About a hundred dollars, only what it cost us to raise


and feed the dog for the three months.”

Judy looked at Allen, who was whispering something to


Lynne.

In that momentary lull she could hear Lynne’s answering


whisper, “But what would we do with him when you’re
away on tour for eight weeks and I’m busy teaching?”

“When do you throw them the meat?” a little boy asked


as they went on among the older dogs.

“We’re not in the zoo, my little friend. No lions or tigers


here,” Mace replied with a grin. “These dogs are never
fed any meat. Up in the Arctic regions, the dogs get
walrus and chunks of seal. But here, it’s not necessary.
See that box of food next to each kennel? When a dog
is hungry, he goes over and eats what he wants of it.
It’s a mixture of the best scientific foods these dogs
require.” He pointed to the pans of water near each
kennel. “They need lots of water during the summer
months, but in the winter the snow is enough.”
“Gee, these dogs are kind of lazy—the way they just sit
around.” Mr. Mace overheard the little boy’s complaint.

Mr. Mace smiled at the boy. “Don’t you think these dogs 149
deserve a rest after working hard from November
through April? This is their vacation, son,” he said kindly.
“That’s how we keep them fit and happy.”

They were now among the full-grown dogs selected for


their team work. “Eight, ten, sometimes twelve dogs
make a team,” Mr. Mace explained, “depending on the
distance to be traveled and the load to be pulled. The
dogs are harnessed in pairs, but the leader runs in
single harness in front. Teams must be well matched,
not only for beauty and appearance, but in strength and
size. But the leader is the prize of the pack—like this
one here.” Mr. Mace bent over to pet him.

“He’s pure Malamute strain. That’s one of the best. See


his powerful chest, his long bushy tail, like the others,
only longer and bushier. Look at his feet, those powerful
nails, the short hair cushioning the toes, the long hair
between. He is sure-footed, intelligent, and has a fine
sense of smell. Never forgets a road once he’s been
over it, never forgets commands once they’ve been
mastered. And he has character! Don’t laugh,” he smiled
at Judy. “This dog has got character. He demands
obedience from his team. Where he goes, the team
must follow.”

Mr. Mace turned his attention to a large handsome dog


that seemed unresponsive to his petting. “She’s Eskimo,
and she’s brooding. We took away her puppies some
days ago and she’s still unhappy.”
A little boy, more venturesome than the others, went
over to her. “Don’t go near her,” Mr. Mace said. “She’s
not vicious, none of them are, but she’s best left alone
at present.”

The crowd moved on. The boy who had just been
admonished stood in front of the kennel watching the
sulky animal. As Judy tried to pass, the boy stood
talking to the dog.

“What’s the use of being sore?” He stepped closer.


“Come on, let’s shake hands.”

The dog lifted her leg and gave the boy’s chest a shove. 150
He went down as if hit by a load of bricks. The boy lay
there, stunned. Judy screamed, “Mr. Mace! Mr. Mace!”

It was her frightened call that brought Mr. Mace loping


back. He picked up the frightened boy and said severely,
“You’re not hurt, but I warned you to let that dog
alone.”

Mr. Mace walked on and the group, a little sobered,


followed.

“How much cold can these dogs stand?” Lynne asked.

“In the far north they can take a temperature that goes
to sixty or seventy degrees below zero. We, of course,
haven’t such extremes of cold here, but it’s plenty cold
in the mountains in the winter. When we take people on
our sledding trips over snow-covered trails, we stop
overnight at a cabin we’ve built. Our riders enjoy a good
fire, a comfortable bed and a meal.

“But,” he went on, “the dogs are just unharnessed, fed,


and go to sleep in the snow. You’ve noticed these
Huskies have thick coats of fur and nature further
protects them with a wool matting close to their hide.
So you see,” and he smiled at Lynne, “these dogs can
stand all kinds of weather.”

“Look at that dog there,” a woman exclaimed. “I’ve


never seen such a handsome dog! His black markings
on the forehead and nose are so striking against his
white coat!” All turned to look. “See how he stands
there as if he enjoyed our admiration.”

“Of course, she does,” Mr. Mace said. “She’s our prima
donna, one of our famous movie stars. She’s only
completely happy when she’s in front of a movie
camera.”

“Can she do some tricks for us now, please?”

“I’m afraid not. Our dogs have performed often right out
here in these very mountains. You’ve probably seen
them on your own TV’s at home, thinking they were
made in the Arctic! But most often when Hollywood
needs our dogs, we just board a plane and go there.”

There was more, much more. Eighty dogs are a lot of 151
dogs to see and Judy must have looked as she felt, very
weary. The tour was over.

As they neared the exit, Mr. Mace turned to the crowd


still following him. “Like to hear my dog concert?”

“Sure!” everyone said.

“Kyloo,” Mr. Mace addressed a powerful Husky whose


kennel was near, “how about some music for these nice
people?”
Kyloo didn’t seem interested.

“Now come on, Kyloo,” Mr. Mace’s voice was coaxing.


“Don’t be shy. I’ll start you off.”

Mr. Mace thrust back his head and a loud, prolonged


wail came from his throat.

Kyloo didn’t need any more urging. He tilted back his


head, opened his wide jaws and the same powerful,
prolonged note issued from his throat. It re-echoed
through the grove and grew in volume as the wail was
taken up by the eighty dogs.

It was a strange, primitive call, high and piercing. Yes, it


was a kind of song, the dogs’ farewell to the visitors,
farewell in music.

While Allen stayed on to take some snapshots of the


dogs, Lynne and Judy followed others into the Arctic
Trading Shop, a lovely log cabin displaying rare and
unusual things. When at last Allen joined them, they
returned to the car to drive back to Aspen.

It was only as they drove through Main Street past the


Ski Lodge and Chairlift that Judy suddenly remembered.

“Allen,” she said, putting her hand on the wheel, “aren’t


we going up the Chairlift? You promised!”

“Judy, I hate to say it, but the answer is ‘no.’”

“Why?” she asked, unable to hide her disappointment.

“Well,” Allen said slowly as if to lessen the blow, “chiefly 152


because Lynne and I went up last Saturday.”
“You went up?” Judy repeated, reluctant to believe such
treachery, going up without her!

Allen nodded. “You see, a lot of Festival people planned


the trip, getting some special rate and Lynne and I
couldn’t resist a bargain! But, Judy,” Allen smiled
sheepishly, “I think we’re sort of glad you weren’t along
to witness our disgrace. We got off at Midway!”

“How could you get off when the chairs keep moving all
the time? The machinery never stops. I’ve watched it a
hundred times.”

“Well, it takes a bit of agility, but everyone has to get off


at Midway for a few minutes. The mechanism changes
direction at that point. You walk a few feet and leap on
again. That’s where the chair immediately swings out
over a bottomless chasm! I decided I had enough!
Dangling like a clothes hanger from that slender cable
was too much for me. I had no stomach to ride over
that yawning abyss and then ascend to thirteen
thousand feet!”

Judy looked at Lynne. “Is he joking? He gave up just


like that?”

“We gave up, just like that,” Lynne said laughing. “Allen
shouted to me, ‘I’m getting off at Midway. Not going
further. You keep going if you wish, but I don’t think it
sensible.’

“Jouncing along, my nerves a bit jittery, I guess I was


secretly glad and yelled back, ‘I will too.’ My young
campers were below me, swinging along, waving their
hands and laughing. I knew we would have to brave
their jeers, if not their scorn. But we did.” Lynne and
Allen exchanged glances as if there were some reason
for their lack of hardihood.

“So like a cautious young couple with good reasons for 153
our caution,” again that special smile for Allen, “we
walked down a steep mining road that took us back to
Aspen. It was wonderful even if we didn’t get to the
top.”

Allen patted Judy’s shoulder. “I guess it isn’t so bad


when the mountains and the chasm are blanketed in
snow. Leave something for another time or another
year. You’ll be coming to Aspen again. Everyone does.”

“I hope so,” Judy said with forced resignation. Then she


remembered Ashcroft and the dogs. “It’s been such a
perfect day. How can I ever thank you!”

The car pulled up in front of Judy’s house. “I’m sorry we


can’t stop in—marketing, and dinner still to get,” Lynne
said. “We’ll see Mother and Dad in a few days—we have
something very special to tell them.”

Judy wondered.

Lynne went on, “You know, Allen and I feel flattered.


You didn’t mention Karl’s name once all day!”

“But that doesn’t mean that I didn’t think of him.


Everytime I looked at those gorgeous Eskimo dogs with
their sad, dreamy eyes, I thought of Karl. Isn’t that
strange?”

“Truth is stranger than fiction,” Lynne laughed. “I’m


afraid you’ve got a real case! Good-bye, dear!”

“Good-bye!”
“Something special to tell them?” Judy repeated to
herself as she slowly mounted the porch steps. “Maybe
that’s why Allen didn’t want Lynne to go further on the
Chairlift. After all, they are married two years—”

154
14
“CONFIDENTIALLY YOURS”

“... and so, dear Grandpa, I’ve brought you up on all the
latest news. One or two things more. Mother is still
hopeful for an early audition for the City Center Opera
Company. Father continues to write incomprehensible
notes on his music sheets—and literally walks on air
when it goes well. Other times he just looks black and
frustrated, staring into space as if listening. But his work
at the school is fine. And his quartet is making a name
for itself in this oasis we call Aspen. There! That’s
enough about them!

“I can see you look at me in that way you have and say,
‘What about you?’

“That’s not so easy to answer. Part of me is getting


along swimmingly. Lynne says I have a gift with
children! Imagine, I who during those first days at camp
felt like wringing their individual and collective necks!

“Happy as I am to have that wonderful job, that’s not 155


the important thing in my life. Mother is blind and so is
Father! The great change in my life—in me, has come
since I’ve known Karl! When I first wrote to you about
him, I told you of his looks, his love and knowledge of
music, his almost unnatural devotion to his mother! But
our friendship, oh so necessary to both of us, has
deepened, has matured into something quite wonderful!
Please don’t smile. I couldn’t bear it and somehow I
know you won’t or I wouldn’t be writing as I do.

“When I see him, his nearness gives me a joy I can’t


explain. We see each other nearly every day—if not at
his Uncle Yahn’s Swiss Shop, then he drops in here. We
never finish all we have to say. I know his character, his
thoughts, his dreams. I weep for all his father has been
through. Remember the prophets of the Old Testament
you used to read to me? I listened with only half an ear.
But Karl knows a lot of Jewish history and I’m learning
fast. When Grandma hears of this phenomenon, she will
be glad that all her efforts to fill the huge gap in my
ignorance has at last born fruit. I’m beginning to
glimpse what she used to call ‘our great heritage.’

“But Mother sees little of all this greatness in Karl. She


treats him like any other music student.

“‘How are things going, Karl?’ Then she’s off to the


kitchen or marketing or sometimes, more lately, to rest.
Father is more interested, but he too is preoccupied
with his own work. So I have become more necessary
to Karl as he is to me.

“I love him! There, I have written the word. I dream of


what he’ll be some day, how I can help and how I can
become that which he seems to see in me. Will our
discovery of each other in Aspen flower into something
as wonderful as the present? Don’t tell me I’m young!
Juliet was only fifteen! Happily for us, there are no
Montagues and Capulets with their senseless feuds to
try to keep us apart!

“I know my own feelings, but how can I know that Karl


loves me? I do know he likes me a lot, but even so,
there are complications!

“Karl works with a pianist and she’s fiendishly clever! 156


She’s pretty, very superior, and treats me like a child!
She’s old, at least twenty. For all that, she looks so
dainty and petite. And I’m awkward, stupid and tongue-
tied when I’m with her.

“Karl asked me to meet her. I was terribly curious about


her and agreed although I knew in advance I wouldn’t
like her. Twice was enough! I’ll not subject myself again
to such humiliation. I asked him why he allowed her to
order him around and make jokes about the most
serious things?

“His only answer was, ‘She knows her piano. I don’t. I’m
lucky to get that ribbing. It helps to keep one’s feet on
the ground. Besides, she’s fun to be with!’

“He looked at me in surprise. ‘You used to have a sense


of humor, Judy. What’s become of it? I hoped you’d
enjoy Marian as much as I do.’

“I couldn’t tell him I never want to see her again! She


stirs up the ignoble in me. I know, at least I feel, she’s
trying to entice Karl, trying to get him in her clutches,
away from me. Probably, she recognizes the genius he’ll
become some day! I try not to think of her and often I
forget her completely, especially when Karl and I are
together, alone.

“Good-bye, Grandpa. Keep well and know I love you.


This letter is for you only. I won’t mail it until I’ve
written another for Grandma with all the concerts,
lectures (ugh!), recitals and rehearsals—in short, with
all the news that’s fit to print. O.K.?
Lovingly and confidentially yours,
Judy”

157
15
THE MOUNTAIN CLIMB

It was the middle of August and the season in Aspen


was drawing to a close. In a little more than two weeks,
the students of the Festival would begin to trickle back,
some to college, others to jobs. The artists and faculty
members were already speaking of their fall
engagements to travel all over the United States,
Canada, and South America.

But in the meantime, as if the planners of the Music


Festival wished to end the Festival in a blaze of glory,
life in Aspen increased to a furious tempo. Lectures,
recitals, concerts, music in one form or another filled
the days and nights. No one seemed to feel the strain
except Judy. She wondered sometimes, did the nearby
mountains ever tire of this constant paean of music?

One evening Mrs. Lurie casually announced at dinner,


“We’re all going tonight to a lecture at the Seminar
Building.” She turned to Judy. “You remember that
attractive ultramodern building near the Tent? You loved
the paintings exhibited there on those circular walls.”
She shook her head meditatively, “Those paintings by
American artists were given by Mr. Paepcke. He’s
certainly been very generous.”

“Allen and Lynne are going to pick us up in their car,”


her mother went on cheerfully. “Oh, here they are!”
After the usual greetings, Mrs. Lurie said, “Judy’s 158
coming with us. The lecture will be over by ten.”

“What’s the lecture about?” Judy asked.

Her mother answered, “‘Modern Trends in Disharmony.’


It should be wonderful!”

Judy shuddered. She remembered other “wonderful


lectures” through which she had sat bored and
rebellious. In that brilliantly lighted hall one had not
even the small luxury of being able to fall asleep!

“They’re playing a wonderful Western at the Isis,” Judy


said desperately.

“A Western!” her mother and Lynne said. “They’re


dreadful!”

“Oh, I don’t know,” Allen said quite unexpectedly.


“Daredevil riding on magnificent horses, hairbreadth
escapes, mountain scenes like our Rockies—” His eyes
flashed. “They’re packed with excitement—loads of it.”

Judy looked at Allen, then shifted her gaze to her father.


In his eyes too there was more than a glint of interest.

“Come to think of it,” Allen went on, “it’s funny, we


haven’t been to a movie all summer.”

“What’s funny about that?” Lynne asked with marked


disappointment at Allen’s bourgeois taste in films. “Of
course, we haven’t been to a movie, nor have we seen
any television. And we certainly haven’t missed either.”
She looked for encouragement to Mr. Lurie as she went
on.
“Who wants to see gun-shooting, Hollywood cowboys
tearing up and down mountains when one can enjoy a
delightful evening listening to ‘Modern Trends’!” She
smiled at John certain of his unqualified support.

Instead of an answering smile, he cleared his throat and 159


said with a deprecating air, “I agree with Allen. There’s
something to be said for these Westerns. The sight of
horses leaping from crag to crag, men hurled from
saddles, climbing inch by inch over backbreaking trails
—” He laughed and shrugged his shoulders. “It fills me
with a nostalgia.”

“But this lecture, John,” Minna said in a quiet,


determined voice, “is by one of the foremost
musicologists.”

“One of the greatest,” Lynne added.

Allen placed his large, friendly hands on Judy’s


shoulders. “Have a heart, Lynne. This kid has listened to
music and lectures without let-up for seven long weeks.
Sure, it’s been great, but maybe she’d like a change of
diet.”

There was a flurried consultation between Lynne and


Minna. Then with a martyrlike smile, Lynne said, “Allen,
dear, since you feel so strongly about Judy’s state of
mind, of course, we’ll go to the Isis.”

Allen brazenly winked at John. Then everyone laughed.


Judy was unable to see the joke. As they walked along
the quiet streets, seeing her father and Allen in such
high spirits, she wondered. Had they made all that fuss
on her account or were they satisfying some secret
desire of their own?
The very next day John Lurie announced his decision to
climb Maroon Peak on Sunday. All summer he had been
promising himself one good climb. The movie did it! As
Judy phrased it, “The close-up of the mountain trails
whetted his ‘blunted purpose,’” something she had
culled from her favorite play of Shakespeare. Whatever
the reason, John Lurie cleared his calendar and made
his plans.

Fran accepted the role of guide, since he knew the trails


well. Karl was invited “to please a certain nameless
young lady,” he said. “Oh, Father!” came ecstatically
from Judy at this bit of news. Minna was invited but
refused as she didn’t feel equal to so difficult a climb
and might spoil the day for the others.

The final arrangements were discussed. Extra jackets 160


and sweaters were to be taken in their knapsacks as the
summit was often bitterly cold, even in summer. Each
one was to provide his own sandwiches and a drink of
some kind or water in a canteen and heavy socks and
shoes were to be worn. The agreed to meet at eight
o’clock in the morning at the foot of the trail twelve
miles from Aspen. Judy and her father were getting a
lift through the kindness of a neighbor, but Fran
cheerfully volunteered not only to get Karl and himself
to the trail, but also to have a car meet them at seven
that night to take them back to Aspen.

The night before the climb Judy lay in bed unable to


sleep. A whole day with Karl ahead of her! She felt like a
general mapping out her strategy. Her father would race
ahead with Fran, but she, affecting an air of languor
(lovely thought, she hoped she could bring it off!) would
set a slower pace and Karl, with his usual consideration,
would be beside her. She sighed luxuriously. There
would be hours and hours to talk! And at the summit,
resting amid the clouds, they would read poetry! She
had slipped a volume of her grandfather’s poems into
the knapsack, just in case—although she knew a few of
them by heart.

As she tossed on her bed, the thought of Marian


crossed her mind. Karl hadn’t mentioned her name in
days, yet her pretty face still troubled Judy. Jealous! Of
course not! That was over and done with. “Jealousy was
degrading,” she muttered into the pillow, turning it for
the tenth time. It was good to feel cleansed and serene.
But a sweet and consoling thought lulled her to sleep.
The words repeated themselves like a lullaby: “Marian
would soon return to Chicago. Soon, soon—the sooner,
the better!”

“Judy, you’re a fine one to depend on! I thought you’d 161


be up at dawn.” It was her father, fully dressed, ready
for their trip.

They reached the trail long ahead of the scheduled


time. During the half-hour wait the crystal-clear air gave
Judy such an appetite that she consumed a sandwich
and was nibbling on a hard boiled egg when her father
rescued what remained of her lunch and replaced it in
his knapsack.

At the sound of a motor Judy jumped up, “Here they


are!”

A beautiful, shiny, black convertible roared toward them,


swung into the brush and came to a stop. She stared at
it. Every car in Aspen was laden with weeks of dust. No
one they knew ever bothered to clean a car that would
get just as dusty an hour later.
Fran stepped out of the car and walked toward them.
His face was shining, his heavy boots were laced to the
knees, and a coil of rope and knapsack were jauntily
slung over his shoulder.

“Where’s Karl?” Judy asked as he came nearer.

“He’s here. Like a real gentleman, he’s helping the lady.”

“The lady?” Judy repeated stupidly, her eyes fixed on


the car.

Yes! There she was walking with Karl, a hand on his


arm, a dainty figure in dark blue jeans, a cap to match
and a bright red sweater. It couldn’t be—No!—that was
impossible!

They approached slowly. Karl, with a battered old


rucksack borrowed from his uncle, heavy-booted and
heavy of tongue, smiled feebly, “I hope you won’t mind.
Marian begged to come along.”

Marian gave Judy a little nod and held out her pretty
manicured hand to Mr. Lurie. “I know I’m just an
interloper, but to be in the heart of the Rockies and not
able to boast of one little climb—” She gave Mr. Lurie a
ravishing smile.
“Little climb,” Judy muttered under her breath, but she 162
noticed that her father looked as pleased as Punch and
said, “We’re delighted to have you come along.”

“That’s sweet of you, Mr. Lurie.” Then as if just


remembering Judy’s existence, she said, “How are you?”
And without waiting for an answer continued, “I bet
you’re glad not to be the only girl in the party!”

“Well, let’s get started,” Fran said. “We’ve a novice with


us,” he chuckled. “Marian may look like an ad for the ski
patrol, but, brother, she’s never climbed a mountain
except in a car. Well, there always has to be a first time.
Besides, if we hadn’t Marian’s car, we would have had to
hike the twelve miles to get here. The guy who was to
take us found himself with five passengers for Denver. A
break for him, but—”

Judy stood in the circle and except for a hollow “Hello,


Marian,” had been too numb to say anything. Her heart
was sore with all her useless, foolish planning. As her
grandmother remarked when an irrepressible neighbor
invaded her privacy with stupid visits and more stupid
conversation, “This neighborhood was always so lovely.
Now she has to move next door. There’s always a fly in
the ointment!”

Mr. Lurie was laughing at something Marian was saying.


He turned to Fran, “Maybe you’re right about the stylish
outfit, but why didn’t you tell Marian to wear heavy
shoes?”

“I did tell her.”

“They both did,” Mirian said with a careless shrug. “But I


don’t own a pair of delightfully sensible cowhide boots
such as Judy is sporting.”

Only Judy noticed the subtle sarcasm, “delightfully


sensible.” She looked at her thick socks, the mud-
colored boots inherited from her mother’s climbing era.
She clenched her teeth.

“Don’t worry about me,” Marian added lightly. She lifted 163
a trim little foot. “These sneakers are the best—new and
strong. I’ll manage.”

Judy said nothing but silently prayed those sneakers of


hers would fall apart and expose her bleeding toes on
the rocks.

They began to climb in single file. The first half hour


was easy, a slow upward grade. Marian’s teasing voice
could be heard.

“You call this a climb?”

She talked incessantly until Fran told her brusquely to


save her breath. “You’ll need it,” he warned.

The next three or four hours were hard. Fran leaped


ahead like a goat while Judy and her father, with set
faces and their bodies bent forward, plodded steadily
on. Breathing hard and frequently panting, they were
glad of the rest periods Fran ordered at fifteen-minute
intervals. The trail led over rocks and huge boulders,
mud ankle deep from hidden springs. The trees grew
more sparse, then disappeared altogether. In spite of
herself, Judy was enjoying the climb, the exertion, the
clear, exhilarating air, the sudden views of deep chasms
that fell away a thousand feet.
Of Karl and Marian they saw nothing after the first hour.
Every once in a while Fran would give his weird call,
“Halloo,” and on hearing a faint answering “Halloo,”
would say briefly, “They’re on the trail. O.K. Let’s keep
moving.”

At one-fifteen the three stopped for lunch. They were


on a plateau of smooth rock and before eating, they
rested, lying down on the hard surface to dry their
soaked shirts and perspiring bodies, then turned over on
their stomachs, warming their backs in the hot rays of
the sun. In five minutes they were completely refreshed
and sat up to eat and marvel at the view.

Giant peaks cut into the sky, deep forests of black pine 164
were far below, and in the distance a thread of silver
shimmered, a river, perhaps unknown, uncharted on any
map. In a craterlike hollow, barely seen at first, lay a
lake of dazzling color, like a giant emerald, sparkling in
the sun.

Mr. Lurie at last broke the silence. “You know,” he said


in a meditative voice, “it’s hard to explain one’s love for
mountain climbing to anyone who doesn’t share your
enthusiasm. Most people see it as a foolhardy,
backbreaking, unnecessary exertion. ‘Knock yourself
out! For what?’ they ask with undisguised
condescension, sometimes with a sort of incredulous
contempt. And we lovers of the sport can’t explain.” He
flung out his arms in a sort of ecstasy. “We say it’s the
extraordinary view one gets as a reward for the
struggle. No,” Mr. Lurie continued, letting his arms drop
beside him, “you get an incomparable view from Pike’s
Peak driving up in a car or bus. No, it isn’t the view
alone.”
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like