0%

Book Description

Suitable for newcomers to computer science, A Concise Introduction to Programming in Python provides a succinct, yet complete, first course in computer science using the Python programming language.

The book features:

  • Short, modular chapters with brief and precise explanations, intended for one class period
  • Early introduction of basic procedural constructs such as functions, selection, and repetition, allowing them to be used throughout the course
  • Objects are introduced in the middle of the course, and class design comes toward the end
  • Examples, exercises, and projects from a wide range of application domains, including biology, physics, images, sound, mathematics, games, and textual analysis
  • No external libraries are required, simplifying the book’s use in common lab spaces

Each chapter introduces a main idea through a concrete example and a series of exercises. Designed to teach programming in a concise, yet comprehensive way, this book provides a timely introduction for students and anyone interested in learning Python.

Table of Contents

  1. Preliminaries
  2. Series
  3. Code Listings
  4. Preface
    1. To Instructors
    2. Feedback
    3. Acknowledgments
  5. About the Author
  6. Part I Foundations
    1. Chapter 1 Computer Systems and Software
      1. The CPU and RAM
      2. Computer Languages
      3. Compilation and Interpretation
      4. The Python Interpreter
      5. A Python Program
      6. Why Computer Science?
    2. Chapter 2 Python Program Components
      1. Variables
      2. Program Statements and Syntax
      3. Data Types
      4. Expressions
      5. Comments
      6. Recap
    3. Chapter 3 Functions
      1. Defining a Function
      2. Calling a Function
      3. Return Statements
      4. Local Variables
      5. Type Conversions
      6. Testing
    4. Chapter 4 Repetition: For Loops
      1. For Loops
      2. Range
      3. Assignment Shorthands
      4. Accumulation Loops
      5. Runaway Loops
    5. Chapter 5 Computer Memory: Integers
      1. Bits and Bytes
      2. Binary Numbers
      3. Hexadecimal Numbers
      4. Storing Integers
      5. Memory Sizes
    6. Chapter 6 Selection: If Statements
      1. Boolean Expressions
      2. If Statements
      3. Python Turtle Module
      4. Using the Python Documentation
      5. Import Star
      6. Multiple Return Values
    7. Chapter 7 Algorithm Design and Debugging
      1. Developing Algorithms
      2. Comparing Algorithms
      3. Debugging
    8. Chapter 8 Repetition: While Loops
      1. While Loops
      2. Mod Operation
      3. Print Options
      4. Tracing Code by Hand
      5. Nested Loops
    9. Project: Newton’s Method
    10. Chapter 9 Computer Memory: Floats
      1. Binary Fractions
      2. Moral: Use Inequalities with Floats
    11. Chapter 10 Simulation
      1. Random Numbers
      2. Default Arguments
      3. Functions as Parameters
    12. Project: Visualization
  7. Figure 10.1
    1. Figure 10.1
    2. Figure 10.2
    3. Figure 10.3
  8. Part II Collections and Files
    1. Chapter 11 Strings
      1. Indexing
      2. Slicing
      3. Concatenation
      4. In and Not In
    2. Chapter 12 Building Strings
      1. String Accumulators
      2. Loops over Strings
      3. Escape Sequences
    3. Project: ISBN Check Digits
      1. Conditional Expressions
    4. Chapter 13 Computer Memory: Text
    5. Chapter 14 Lists
      1. Lists
      2. Lists Are Like Strings
      3. Lists Are Also Not Like Strings
      4. Random Functions for Lists
      5. Objects and Object Methods
      6. Method Calls
      7. List Methods
    6. Project: Program Performance
    7. Project: Heat Diffusion
    8. Chapter 15 Files
      1. Files
      2. With Statements
      3. File Methods
      4. File Loops
      5. Splitting Strings
      6. Multiple Method Calls
    9. Chapter 16 String Methods
      1. String Methods
      2. The is Comparison
      3. Multiple Assignment and Return
      4. Constants
      5. Import without From
      6. Accessing Web Pages
    10. Project: File Compression
    11. Chapter 17 Mutable and Immutable Objects
      1. Object State
      2. Using Reassignment
      3. Converting to a Mutable Type
    12. Project: Hangman
      1. Software Development
    13. Chapter 18 Dictionaries
      1. Command Line Execution
      2. Dictionaries
      3. Dictionary Operations
      4. Dictionary Methods
      5. Dictionary Loops
    14. Project: ELIZA
    15. Project: Shannon Entropy
      1. Example: Low Entropy
      2. Example: Higher Entropy
      3. Logs
      4. Exercise
    16. Project: Reading DNA Frames
      1. Reading Frames
      2. FASTA Data Files
  9. Part III Selected Topics
    1. Chapter 19 Sound Manipulation
      1. WAV Files
      2. WAV File Parameters and Frames
      3. Tuples Are Immutable Lists
      4. Data Arrays
      5. Context Managers
    2. Chapter 20 Sound Synthesis
      1. Sound Waves
      2. Musical Notes and Frequencies
      3. Frequency and Sine Functions
    3. Figure 20.1
      1. Figure 20.1
      2. Figure 20.2
      3. Figure 20.3
    4. Chapter 21 Image Manipulation
      1. Computer Memory: Images
      2. RGB Color
      3. PPM Images
      4. ImagePPM Objects
      5. Modifying Images
      6. Luminance
      7. Object Fields
      8. What about f?
    5. Project: Image Filters
      1. Applying Filters
    6. Chapter 22 Image Synthesis
      1. Complex Numbers
      2. Complex Numbers in Python
      3. Parameter Tuples
      4. Linear Interpolation
    7. Chapter 23 Writing Classes
      1. Object-Oriented Terminology
      2. Class Definitions
      3. Field Definitions
      4. Method Definitions
      5. Method Calls Inside a Class
      6. Special Methods: __init__() and __str()__
      7. Calling Constructors
    8. Chapter 24 Cooperating Classes
      1. Abstraction
      2. Importing From Your Own Modules
      3. if __name__ == "__main__":
      4. List Comprehensions
      5. Map
    9. Case Study: PPM Image Class
      1. Class Methods
      2. PPM Image Formats
    10. Chapter 25 Related Classes
      1. The Turtle Class
      2. Inheritance
      3. Superclass Initializer
      4. Class Variables
    11. Chapter 26 Functional Programming
      1. Programming Paradigms
      2. Program Overview
      3. Iterators and Iterables
      4. Grouping List Elements
      5. Lambda Expressions
      6. Recursion
    12. Chapter 27 Parallel Programming
      1. Multiprocessing
      2. Python Multiprocessing Pools
    13. Chapter 28 Graphical User Interfaces
      1. The tkinter Module
      2. Event-Driven Programming
      3. Window Methods
      4. Widgets
      5. Widget Options
      6. IntVar and StringVar
      7. Geometry Managers
      8. Multiple Inheritance
      9. PhotoImages
  10. Bibliography
3.19.30.232