Instant Download Discovering Computer Science Interdisciplinary Problems Principles and Python Programming 2nd Edition Jessen Havill PDF All Chapters
Instant Download Discovering Computer Science Interdisciplinary Problems Principles and Python Programming 2nd Edition Jessen Havill PDF All Chapters
com
https://textbookfull.com/product/discovering-computer-
science-interdisciplinary-problems-principles-and-python-
programming-2nd-edition-jessen-havill-2/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/python-programming-an-introduction-
to-computer-science-john-m-zelle/
textboxfull.com
Python Programming An Introduction to Computer Science 3rd
Edition John M. Zelle
https://textbookfull.com/product/python-programming-an-introduction-
to-computer-science-3rd-edition-john-m-zelle/
textboxfull.com
https://textbookfull.com/product/data-science-from-scratch-first-
principles-with-python-2nd-edition-joel-grus/
textboxfull.com
https://textbookfull.com/product/data-science-from-scratch-first-
principles-with-python-2nd-edition-grus-joel/
textboxfull.com
https://textbookfull.com/product/practical-programming-an-
introduction-to-computer-science-using-python-3-6-3rd-edition-paul-
gries/
textboxfull.com
https://textbookfull.com/product/programming-interview-problems-
dynamic-programming-with-solutions-in-python-1st-edition-leonardo-
rossi/
textboxfull.com
Discovering Computer Science
Chapman & Hall/CRC
Textbooks in Computing
Series Editors
John Impagliazzo
Andrew McGettrick
Pascal Hitzler, Markus Krötzsch, and Sebastian Rudolph, Foundations of Semantic Web Technologies
Henrik Bærbak Christensen, Flexible, Reliable Software: Using Patterns and Agile Development
John S. Conery, Explorations in Computing: An Introduction to Computer Science
Lisa C. Kaczmarczyk, Computers and Society: Computing for Good
Mark Johnson, A Concise Introduction to Programming in Python
Paul Anderson, Web 2.0 and Beyond: Principles and Technologies
Henry Walker, The Tao of Computing, Second Edition
Ted Herman, A Functional Start to Computing with Python
Mark Johnson, A Concise Introduction to Data Structures Using Java
David D. Riley and Kenny A. Hunt, Computational Thinking for the Modern Problem Solver
Bill Manaris and Andrew R. Brown, Making Music with Computers: Creative Programming in Python
John S. Conery, Explorations in Computing: An Introduction to Computer Science and Python Programming
Jessen Havill, Discovering Computer Science: Interdisciplinary Problems, Principles, and Python
Programming
Efrem G. Mallach, Information Systems: What Every Business Student Needs to Know
Iztok Fajfar, Start Programming Using HTML, CSS, and JavaScript
Mark C. Lewis and Lisa L. Lacher, Introduction to Programming and Problem-Solving Using Scala,
Second Edition
Aharon Yadin, Computer Systems Architecture
Mark C. Lewis and Lisa L. Lacher, Object-Orientation, Abstraction, and Data Structures Using Scala,
Second Edition
Henry M. Walker, Teaching Computing: A Practitioner’s Perspective
Efrem G. Mallach, Information Systems:What Every Business Student Needs to Know, Second Edition
Jessen Havill, Discovering Computer Science: Interdisciplinary Problems, Principles, and Python
Programming, Second Edition
For more information about this series please visit:
https://www.crcpress.com/Chapman--HallCRC-Textbooks-in-Computing/book-series/CANDHTEXCO
MSER?page=2&order=pubdate&size=12&view=list&status=published,forthcoming
Discovering Computer Science
Interdisciplinary Problems, Principles, and
Python Programming
Second Edition
Jessen Havill
Second edition published 2021
by CRC Press
2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN
The right of Jessen Havill to be identified as author of this work has been asserted by him in accordance with sections
77 and 78 of the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this book may be reprinted or reproduced or utilised in any form or by any electronic,
mechanical, or other means, now known or hereafter invented, including photocopying and recording, or in any infor
mation storage or retrieval system, without permission in writing from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the
Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are
not available on CCC please contact [email protected]
Trademark notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Preface xv
Acknowledgments xxiii
v
vi • Contents
Data visualization 62
2.3 FUNCTIONAL ABSTRACTION 66
Function parameters 69
2.4 PROGRAMMING IN STYLE 77
Program structure 78
Documentation 79
Tangent 2.2 Global variables 80
Self-documenting code 83
2.5 A RETURN TO FUNCTIONS 87
The math module 88
Writing functions with return values 89
Return vs. print 92
2.6 SCOPE AND NAMESPACES 97
Local namespaces 98
The global namespace 101
2.7 SUMMARY AND FURTHER DISCOVERY 105
*
Sections with *** in lieu of a page number are available on the book website.
Contents • vii
Negative integers
Designing an adder
Implementing an adder
3.5 THE UNIVERSAL MACHINE 124
3.6 SUMMARY AND FURTHER DISCOVERY 126
Bibliography 501
Index 505
Preface
I nthree
my view, an introductory computer science course should strive to accomplish
things. First, it should demonstrate to students how computing has become
a powerful mode of inquiry, and a vehicle of discovery, in a wide variety of disciplines.
This orientation is also inviting to students of the natural and social sciences, and the
humanities, who increasingly benefit from an introduction to computational thinking,
beyond the limited “black box” recipes often found in manuals and “Computing
for X” books. Second, the course should engage students in computational problem
solving, and lead them to discover the power of abstraction, efficiency, and data
organization in the design of their solutions. Third, the course should teach students
how to implement their solutions as computer programs. In learning how to program,
students more deeply learn the core principles, and experience the thrill of seeing
their solutions come to life.
Unlike most introductory computer science textbooks, which are organized around
programming language constructs, I deliberately lead with interdisciplinary problems
and techniques. This orientation is more interesting to a more diverse audience, and
more accurately reflects the role of programming in problem solving and discovery.
A computational discovery does not, of course, originate in a programming language
feature in search of an application. Rather, it starts with a compelling problem which
is modeled and solved algorithmically, by leveraging abstraction and prior experience
with similar problems. Only then is the solution implemented as a program.
Like most introductory computer science textbooks, I introduce programming skills
in an incremental fashion, and include many opportunities for students to practice
them. The topics in this book are arranged to ease students into computational
thinking, and encourage them to incrementally build on prior knowledge. Each
chapter focuses on a general class of problems that is tackled by new algorithmic
techniques and programming language features. My hope is that students will leave
the course, not only with strong programming skills, but with a set of problem
solving strategies and simulation techniques that they can apply in their future work,
whether or not they take another computer science course.
I use Python to introduce computer programming for two reasons. First, Python’s
intuitive syntax allows students to focus on interesting problems and powerful
principles, without unnecessary distractions. Learning how to think algorithmically
is hard enough without also having to struggle with a non-intuitive syntax. Second,
the expressiveness of Python (in particular, low-overhead lists and dictionaries)
expands tremendously the range of accessible problems in the introductory course.
xv
xvi • Preface
Teaching with Python over the last fifteen years has been a revelation; introductory
computer science has become fun again.
Problem solving The new first chapter, How to Solve It, sets the stage by focusing on
Polya’s elegant four-step problem solving process, adapted to a computational frame
work. I introduce informal pseudocode, functional decomposition, hand-execution
with informal trace tables, and testing, practices that are now carried on throughout
the book. The introduction to Python (formally Chapter 2) is integrated into this
framework. Chapter 7, Designing Programs, from the first edition has been elimi
nated, with that material spread out more naturally among Chapters 1, 5, and 6 in
the second edition.
Chapter 2, Visualizing Abstraction (based on the previous Chapter 3), elaborates on
the themes in Chapter 1, and their implementations in Python, introducing turtle
graphics, functions, and loops. The new Chapter 3, Inside a Computer (based on
the previous Sections 1.4 and 2.5), takes students on a brief excursion into the simple
principles underlying how computers work.
Online materials To reduce the size of the printed book, we have moved some
sections and all of the projects online. These sections are marked in the table of
contents with ***. Online materials are still indexed in the main book for convenience.
Exercises I’ve added exercises to most sections, bringing the total to about 750.
Solutions to exercises marked with an asterisk are available online for both students
and self-learners.
Digital humanities The interdisciplinary problems in the first edition were focused
primarily in the natural and social sciences. In this edition, especially in Chapters 1,
6, and 7, we have added new material on text analysis techniques commonly used in
the “digital humanities.”
Book website
Online materials for this book are available at
https://www.discoveringCS.net.
Here you will find
To students
Active learning Learning how to solve computational problems and implement
them as computer programs requires daily practice. Like an athlete, you will get
out of shape and fall behind quickly if you skip it. There are no shortcuts. Your
instructor is there to help, but he or she cannot do the work for you.
With this in mind, it is important that you type in and try the examples throughout
the text, and then go beyond them. Be curious! There are numbered “Reflection”
questions throughout the book that ask you to stop and think about, or apply,
something that you just read. Often, the question is answered in the book immediately
thereafter, so that you can check your understanding, but peeking ahead will rob
you of an important opportunity.
Further discovery There are many opportunities to delve into topics more deeply.
“Tangent” boxes scattered throughout the text briefly introduce related, but more
technical or applied, topics. For the most part, these are not strictly required to
understand what comes next, but I encourage you to read them anyway. In the
“Summary and Further Discovery” section of each chapter, you can find both a
high-level summary of the chapter and additional pointers to explore chapter topics
in more depth.
Exercises and projects At the end of most sections are several programming exercises
that ask you to further apply concepts from that section. Often, the exercises assume
that you have already worked through all of the examples in that section. Solutions
to the starred exercises are available on the book website. There are also more
involved projects available on the book website that challenge you to solve a variety
of interdisciplinary problems.
Have fun! Programming and problem solving should be a fun, creative activity. I
hope that this book sparks your curiosity and love of learning, and that you enjoy
the journey as much as I have enjoyed writing this book.
To instructors
This book is appropriate for a traditional CS1 course for majors, a CS0 course for
non-majors (at a slower pace and omitting more material), or a targeted introductory
computing course for students in the natural sciences, social sciences, or humanities.
The approach is gentle and holistic, introducing programming concepts in the context
of interdisciplinary problems. We start with problem-solving, featuring pseudocode
and hand-execution with trace tables, and carry these techniques forward, especially
in the first half of the book.
Problem focus Most chapters begin with an interesting problem, and new concepts
and programming techniques are introduced in the context of solving it. As new
techniques are introduced, students are frequently challenged to re-solve old problems
in different ways. They are also encouraged to reuse their previous functions as
components in later programs.
Additional instructor resources All of the reflection questions and exercises are
available to instructors as Jupyter notebooks. Solutions to all exercises and projects
are also available. Please visit the publisher’s website to request access.
Python coverage This book is not intended to be a Python manual. Some features
of the language were intentionally omitted because they would have muddled the core
problem solving focus or are not commonly found in other languages that students
may see in future CS courses (e.g., simultaneous swap, chained comparisons, zip,
enumerate in for loops).
Topic coverage There is more in this book than can be covered in a single semester,
giving instructors the opportunity to tailor the content to their particular situation
Preface • xix
Chapter 6
Chapter 7 Chapter 5
Text, Documents,
Data Analysis Forks in the Road
and DNA
Chapter 9
Chapter 8 Chapter 10
Self-similarity and
Flatland Organizing Data
Recursion
Chapter 12
Chapter 11
Object-oriented
Networks
Design
and interests. As illustrated in Figure 1, Chapters 1–7 form the core of the book, and
should be covered sequentially. The remaining chapters can be covered, partially or
entirely, at your discretion, although I would expect that most instructors will cover
at least parts of Chapters 8–10, and 12 if the course covers object-oriented design.
Chapter 11 introduces social network graphs and small-world and scale-free networks
as additional powerful applications of dictionaries, and may come any time after
Chapter 7. Sections marked with an asterisk are optional, in the sense that they are
not assumed for future sections in that chapter. When exercises and projects depend
on optional sections, they are also marked with an asterisk, and the dependency is
stated at the beginning of the project.
Chapter outlines The following tables provide brief overviews of what is available
in each chapter. Each table’s three columns, reflecting the three parts of the book’s
subtitle, provide three lenses through which to view the chapter.
1 How to Solve It
Sample problems Principles Programming
● reading level ● problems, input/output ● int, float, str types
● counting syllables, words ● functional abstraction ● arithmetic
● sphere volume ● functional decomposition ● assignment
2 Visualizing Abstraction
3 Inside a Computer
Principles Programming
● computer organization ● int and float types
● machine language ● arithmetic errors
● binary representations ● true vs. floor division
● computer arithmetic
● finite precision, error propagation
● Boolean logic, truth tables, logic gates
7 Data Analysis
8 Flatland
Sample problems Principles Programming
● earthquake data ● 2-D data ● lists of lists
● Game of Life ● cellular automata ● nested loops
● image filters ● digital images ● 2-D data in a dictionary
10 Organizing Data
● intractability, P=NP?
11 Networks
Sample problems Principles Programming
● social media, web graphs ● graphs ● dictionaries
● diffusion of ideas ● adjacency list, matrix
● epidemics ● breadth-first search
12 Object-oriented Design
Software assumptions
To follow along in this book and complete the exercises, you will need to have
installed Python 3.6 or later on your computer, and have access to IDLE or another
programming environment. The book also assumes that you have installed the
matplotlib.pyplot and numpy modules. The easiest way to get this software is to
install the free open source Anaconda distribution from http://www.anaconda.com.
Errata
While I (and my students) have ferreted out many errors, readers will inevitably find
more. You can find an up-to-date list of errata on the book website. If you find an error
in the text or have another suggestion, please let me know at [email protected].
Acknowledgments
In addition to those who provided their support and expertise for the first edition,
I wish to thank Janet Davis (Whitman College), Jim Deverick (The College of
William and Mary), David Goodwin (Denison University), and Ashwin Lall (Denison
University) for their valuable feedback on drafts of the second edition.
I would also like to thank Dee Ghiloni, Mary Lucas-Miller, and Tony Silveira for
their steadfast support, Mike Brady and my Data Analytics colleagues for reminding
me how much fun it can be to learn new things, and the Book Group for reminding
me to not take life too seriously. A Bowen Fellowship awarded by Denison University
gave me the time needed to complete this project.
Finally, my family has once again provided me with seemingly infinite patience and
love during this intensive period of writing. I am an extraordinarily lucky husband
and father.
xxiii
About the author
xxv
CHAPTER 1
How to Solve It
We need to do away with the myth that computer science is about computers. Computer
science is no more about computers than astronomy is about telescopes, biology is about
microscopes or chemistry is about beakers and test tubes. Science is not about tools, it is
about how we use them and what we find out when we do.
It has often been said that a person does not really understand something until after teaching
it to someone else. Actually a person does not really understand something until after
teaching it to a computer, i.e., expressing it as an algorithm.
Donald E. Knuth
American Scientist (1973)
C consciously
omputers now touch almost every facet of our daily lives, whether we are
aware of them or not. Computers have changed the way we learn,
communicate, shop, travel, receive healthcare, and entertain ourselves. They are
embedded in virtually everything, from major feats of engineering like airplanes,
spaceships, and factories to everyday items like microwaves, cameras, and tooth
brushes. In addition, all of our critical infrastructure—utilities, transportation,
finance, communication, healthcare, law enforcement—relies upon computers.
Since computers are the most versatile tools ever invented, it should come as
no surprise that they are also employed throughout academia in the pursuit of
new knowledge. Social scientists use computational models to better understand
social networks, epidemics, population dynamics, markets, and auctions. Humanists
use computational tools to gain insight into literary trends, authorship of ancient
texts, and the macroscopic significance of historical records. Artists are increasingly
incorporating digital technologies into their compositions and performances. Natural
1
2 • 1 How to Solve It
Look back at
Understand the Design an Write a
your algorithm
problem algorithm program
and results
1. First, understand the problem. What is the unknown? What are the data?
What is the condition?
2. Second, devise a plan to solve the problem.
3. Third, carry out your plan, checking each step.
4. Fourth, look back. Check the result. Can you derive the result differently?
These four steps, with some modifications, can be applied just as well to compu
tational problem solving, as illustrated in Figure 1.1. In the first step, we make
1
You can learn more about Donald Knuth at the end of this chapter.
Another Random Scribd Document
with Unrelated Content
home. Lucy, who has heard nothing of the feud, makes the
acquaintance of Howe’s three timid sisters, and eventually meets
him. It follows that the two fall in love. On her death bed, Ellen
discovers how matters stand with her niece and neighbor and
determines on final revenge. When her will is read it is found that
she leaves all her property to Howe provided he repairs the long-
disputed wall. Otherwise it is to become the town poor farm. The
situation develops into a battle between Howe’s pride and the
inclinations of his heart. But love, as usual, finds a way out.”—
Springf’d Republican
19–19679
“The grownup lover of pets will enjoy this book of dog, cat and bird
biography much as children enjoy their numerous animal books. The
writer’s fondness for collies is tempered with a sly delightful humor
which relieves the book of sentimentality.”
“She has, in short, made literature out of a dog and enshrined one
lovable member of that remarkable race in a work as thoughtful as it
is delightful. Sigurd, I believe, will take his place among the canine
immortals, along with Greyfriars Bobby, John Muir’s Stikeen, and
the great dogs of fiction.” W. A. Dyer
“It may be that Miss Bates really understands dog nature, but she
has not expressed it here.”
“We like her writing best when it is most bookish. That is its note.
We have other books on our shelves aplenty in which the canine hero
plays a more tragic or pathetic or even humorous rôle, but none in
which he is more humanly literate than Miss Bates’s Sigurd of the
golden fleece.”
“The book reads very much as though the author had started out to
write one kind of a story, then suddenly changed his mind and
proceeded to produce another. This is the more deplorable because
the second part of the book, the war section, is well done and
interesting.”
20–1698
“The very fact that the actors are of various nationalities affords a
wide scope in character drawing and the author has done this work
with an incisive delicacy of feeling which one cannot fail to
appreciate. Humor is not lacking and forceful, thought-compelling
passages add to the graceful style of every story.”
“They are whimsically written. But the regularity with which the
various characters undergo a metamorphosis under the stimulus of
the patriotic impulse becomes wearisome.”
20–20646
20–7092
20–12409
“His theory has not cut him off from vital contact with poetry. The
things of which he is chiefly aware are the essential things, and to
read him is to have the ear quickened to a new enjoyment.”
+ − The Times [London] Lit Sup p668 N 20
’19 1100w
(Eng ed 20–11405)
“No doubt, Mr Bayley has worked hard and honestly. Use him as a
quarry and one will find gold, and, may be, other things. But how
accept his doctrine as a whole?” R. R. M.
20–2834
This work, the author says, was for him not a mere literary
enterprise, but the fruit of close and fervent communion with
Whitman’s work and character. Speaking of Whitman’s universality
he says: “The America which dreams and sings, back of the one
which works and invents, has given the world four universal
geniuses: Poe, Emerson, Thoreau, and Whitman.... And among these
four figures, one of them more and more dominates the group: it is
Walt Whitman.” (Introd.) The translator of the volume from the
French, Ellen FitzGerald, attempts an explanation of the American
masses’ neglect of Whitman, from the geniuses’ inevitable disregard
of “untrained” minds, in deference to whom she has taken it upon
herself to abridge M. Bazalgette’s treatment of the New Orleans
episode and to lighten his emphasis on the “Leaves of grass” conflict.
The book is in eight parts: Origin and youth; The multitudinary life;
“Leaves of grass”; The wound dresser; The good gray poet; The
invalid; The sage of Camden; The setting sun.
Reviewed by B: de Casseres
20–7722
“This latest novel of the gifted Frenchman adds not a single leaf to
his laurel crown. For the most part, the interpretation is labored, and
much space is devoted to moralizing upon the obvious. The general
effect of the novel is accentuated by a translation which is awkward
and infelicitous.”
− Cath World 111:688 Ag ’20 300w
20–14681
The cavalry in the great war was most of the time in little demand,
and had to take its turn in the trenches and at digging parties to
relieve the infantry. “Towards the end of 1917 ... a horse soldier could
hardly pass an infantry detachment on the road without being
greeted by ironical cheers and bitter abuse.” (Foreword) But the time
came when their prestige was reestablished. The war episodes
sketched in the book are the reminiscences of a clergyman attached
to a cavalry brigade. Among the contents are: Joining the squadroon;
Day marching; The gap; The trench party; The devastated area; The
great advance; The last lap.
+ Ath p751 Je 4 ’20 100w
“Those who happen not to have read many ‘war books’ of the kind,
or not to be tired of them, will find these genial, graphic, fluently-
written pages pleasant enough.”
20–21339
20–7573
“Mrs Mary Beard has not only supplied the student of the works of
Professor Commons and his associates with a text-book admirably
lucid and condensed, but she has achieved what is far more difficult
in writing a text-book—especially where no text-book exists—a
connected and in many ways a dramatic story.” A. L. Dakyns
“In her ‘Short history of the American labor movement’ Mrs Beard
performs with interest, competence and wide sympathy a much
needed service.”
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com