You are on page 1of 6

11/21/2020 Algorithmic Problem Solving with Python

School of Electrical Engineering and Computer Science


Washington State University

Algorithmic Problem Solving with Python


I once considered publishing a book that uses Python to introduce folks to programming and algorithmic thinking. But,
why go through the hassle of publishing through a publisher when you can give away something for free? (Okay, I can
think of several reasons, but, as with my book on the Finite-Difference Time-Domain method, I’m going to ignore them!)

I teamed up with Shira Broschat and Jessamyn Dahmen and here is what we have written so far. I consider this to be
something of a work in progress, but many of the sections are rather well polished (as I hope you’ll agree). Here are a
few things to note:

This material is presented “as is.” One of the reasons I’m not trying to publish this via the traditional route is that
I/we lack the time to put all the finishing touches on this material (such as adding full problem sets at the end of
each chapter).
Despite the previous statement, we sincerely welcome any and all suggestions to improve this material. If you
catch a typo or think there is some weakness in this material, please let me know (by sending John Schneider
email at schneidj@eecs.wsu.edu ).
If you find this material useful and see an opportunity to cite it, we would be ever so appreciative of the citation.
Please cite this work as: Algorithmic Problem Solving with Python, John B. Schneider, Shira Lynn Broschat, and
Jess Dahmen, www.eecs.wsu.edu/~schneidj/swan, 2013.
You may download either the entire book (via the link immediately below) or download the individual chapters.
However, this book is completely hyper-linked and many of these hyperlinks break when you split the book into
individual chapters. Thus, unless you can think of a compelling reason to do otherwise, we encourage you to
download the entire book.
Algorithmic Problem Solving with Python by John B. Schneider, Shira Lynn Broschat, and Jess Dahmen is
licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

ENTIRE BOOK: Algorithmic Problem Solving with Python by John B. Schneider, Shira Lynn Broschat, and Jess
Dahmen.

You can also find videos to were designed to accompany the book here:

https://learn.digilentinc.com/classroom/python/.

Haven't yet finish generating all the videos I had hoped to. One of these days!

Individual chapters:

Chapter 1: Introduction
1.1 Modern Computers
1.2 Computer Languages
1.3 Python
1.4 Algorithmic Problem Solving
1.5 Obtaining Python
1.6 Running Python
1.6.1 Interactive Sessions and Comments

https://eecs.wsu.edu/~schneidj/swan/ 1/6
11/21/2020 Algorithmic Problem Solving with Python

1.6.2 Running Commands from a File


1.7 Bugs
1.8 The help() Function
1.9 Comments on Learning New Languages
1.10 Chapter Summary
1.11 Review Questions
Chapter 2: Core Basics
2.1 Literals and Types
2.2 Expressions, Arithmetic Operators, and Precedence
2.3 Statements and the Assignment Operator
2.4 Cascaded and Simultaneous Assignment
2.5 Multi-Line Statements and Multi-Line Strings
2.6 Identifiers and Keywords
2.7 Names and Namespaces
2.8 Additional Arithmetic Operators
2.8.1 Exponentiation
2.8.2 Floor Division
2.8.3 Modulo and divmod()
2.8.4 Augmented Assignment
2.9 Chapter Summary
2.10 Review Questions
2.11 Exercises
Chapter 3: Input and Type Conversion
3.1 Obtaining Input: input()
3.2 Explicit Type Conversion: int() , float() , and str()
3.3 Evaluating Strings: eval()
3.4 Chapter Summary
3.5 Review Questions
3.6 Exercises
Chapter 4: Functions
4.1 Void Functions and None
4.2 Creating Void Functions
4.3 Non-Void Functions
4.4 Scope of Variables
4.5 Scope of Functions
4.6 print() vs. return
4.7 Using a main() Function
4.8 Optional Parameters
4.9 Chapter Summary
4.10 Review Questions
https://eecs.wsu.edu/~schneidj/swan/ 2/6
11/21/2020 Algorithmic Problem Solving with Python

4.11 Exercises
Chapter 5: Introduction to Objects
5.1 Overview of Objects and Classes
5.2 Creating a Class: Attributes
5.3 Creating a Class: Methods
5.4 The dir() Function
5.5 The __init__() Method
5.6 Operator Overloading
5.7 Take-Away Message
5.8 Chapter Summary
Chapter 6: Lists and for -Loops
6.1 list s
6.2 list Methods
6.3 for -Loops
6.4 Indexing
6.5 range()
6.6 Mutability, Immutability, and Tuples
6.7 Nesting Loops in Functions
6.8 Simultaneous Assignment with Lists
6.9 Examples
6.9.1 Storing Entries in a list
6.9.2 Accumulators
6.9.3 Fibonacci Sequence
6.10 Chapter Summary
6.11 Review Questions
Chapter 7: More on for -Loops, Lists, and Iterables
7.1 for -Loops within for -Loops
7.2 list s of list s
7.2.1 Indexing Embedded list s
7.2.2 Simultaneous Assignment and list s of list s
7.3 References and list Mutability
7.4 Strings as Iterables or Sequences
7.5 Negative Indices
7.6 Slicing
7.7 list Comprehension (optional)
7.8 Chapter Summary
7.9 Review Questions
Chapter 8: Modules and import Statements
8.1 Importing Entire Modules

https://eecs.wsu.edu/~schneidj/swan/ 3/6
11/21/2020 Algorithmic Problem Solving with Python

8.2 Introduction to Complex Numbers


8.3 Complex Numbers and the cmath
8.4 Importing Selected Parts of a Module
8.5 Importing an Entire Module Using *
8.6 Importing Your Own Module
8.7 Chapter Summary
8.8 Review Questions
Chapter 9: Strings
9.1 String Basics
9.2 The ASCII Characters
9.3 Escape Sequences
9.4 chr() and ord()
9.5 Assorted String Methods
9.5.1 lower() , upper() , capitalize() , title() , and swapcase()
9.5.2 count()
9.5.3 strip() , lstrip() , and rstrip()
9.5.4 __repr__()
9.5.5 find() and index()
9.5.6 replace()
9.6 split() and join()
9.7 Format Strings and the format()
9.7.1 Replacement Fields as Placeholders
9.7.2 Format Specifier: Width
9.7.3 Format Specifier: Alignment
9.7.4 Format Specifier: Fill and Zero Padding
9.7.5 Format Specifier: Precision (Maximum Width)
9.7.6 Format Specifier: Type
9.7.7 Format Specifier: Summary
9.7.8 A Formatting Example
9.8 Chapter Summary
9.9 Review Questions
Chapter 10: Reading and Writing Files
10.1 Reading a File
10.1.1 read() , close() , and tell()
10.1.2 readline()
10.1.3 readlines()
10.1.4 File Object Used as an Iterable
10.1.5 Using More than One Read Method
10.2 Writing to a File
10.2.1 write() and print()
https://eecs.wsu.edu/~schneidj/swan/ 4/6
11/21/2020 Algorithmic Problem Solving with Python

10.2.2 writelines()
10.3 Chapter Summary
10.4 Review Questions
Chapter 11: Conditional Statements
11.1 if Statements, Boolean Variables, and bool()
11.2 Comparison Operators
11.3 Compound Conditional Statements
11.3.1 if-else Statements
11.3.2 if-elif-else Statements
11.4 Logical Operators
11.5 Multiple Comparisons
11.6 while -Loops
11.6.1 Infinite Loops and break
11.6.2 continue
11.7 Short-Circuit Behavior
11.8 The in Operator
11.9 Chapter Summary
11.10 Review Questions
Chapter 12: Recursion
12.1 Background
12.2 Flawed Recursion
12.3 Proper Recursion
12.4 Merge Sort
Chapter 13: Turtle Graphics
13.1 Introduction
13.2 Turtle Basics
13.2.1 Importing Turtle Graphics
13.2.2 Your First Drawing
13.3 Basic Shapes and Using Iteration to Generate Graphics
13.3.1 Controlling the Turtle's Animation Speed
13.4 Colors and Filled Shapes
13.4.1 Strange Errors
13.4.2 Filled Shapes
13.5 Visualizing Recursion
13.6 Simple GUI Walk-Through
13.6.1 Function References
13.6.2 Callback functions
13.6.3 A simple GUI
Chapter 14: Dictionaries
14.1 Dictionary Basics
https://eecs.wsu.edu/~schneidj/swan/ 5/6
11/21/2020 Algorithmic Problem Solving with Python

14.2 Cycling through a Dictionary


14.3 get()
14.4 Chapter Summary
14.5 Review Questions
Appendix A: ASCII Non-printable Characters

Last updated: December 13, 2018, 15:37.


John Schneider’s home page.

https://eecs.wsu.edu/~schneidj/swan/ 6/6

You might also like