Skip to main content

Introduction to Computer Programming with Python: Contents

Introduction to Computer Programming with Python
Contents
  • Show the following:

    Annotations
    Resources
  • Adjust appearance:

    Font
    Font style
    Color Scheme
    Light
    Dark
    Annotation contrast
    Low
    High
    Margins
  • Search within:
    • Notifications
    • Privacy
  • Project HomeIntroduction to Computer Programming with Python
  • Learn more about Manifold

Notes

table of contents
  1. Cover
  2. Title Page
  3. Copyright Page
  4. Contents
  5. Chapter 1 Introduction
    1. Learning Objectives
    2. 1.1 A Brief History of Computers
    3. 1.2 Fundamentals of Computing and Modern Computers
      1. Number Systems and the Foundation of Computing
      2. Computability and Computational Complexity
      3. The Construction of Modern Computers
        1. Analog Computers
        2. Digital Computers
        3. Mechanic-Based Components
        4. Vacuum Tube–Based Components
        5. Transistors
        6. Integrated Circuits and Very Large-Scale Integrated Circuits
    4. 1.3 Programming and Programming Languages
    5. 1.4 Python Programming Language
      1. The Development and Implementation of Python
      2. Advantages of Python
      3. Resources for Python and Python Education
    6. 1.5 Getting Ready to Learn Programming in Python
      1. Installing and Setting Up the Python Programming Environment
        1. Installing Python
        2. Setting Up a Virtual Environment for a Python Project
        3. Installing Jupyter Notebook
        4. Installing Visual Studio Code
      2. Additional Tools Supporting Software Development in Python
        1. Buildbot
        2. Trac
        3. Roundup
    7. 1.6 Getting a Taste of Programming with Python
      1. Program Interactively with Python Interactive Shell
      2. Program with VS Code IDE
      3. Use Jupyter Notebook Within VS Code to Program Interactively
      4. Write Documentation in Markdown
        1. Headings
        2. Paragraphs
        3. New Lines
        4. Italic, Bold, and Strikethrough Texts
        5. Horizontal Rules
        6. Keyboard Keys
        7. Unordered Lists
        8. Ordered Lists
        9. Definition Lists
        10. Links
        11. Links to Internal Sections
        12. Images
        13. Blockquotes
        14. Tables
        15. Inline Program / Script Code
        16. Code Block
        17. Mathematical Formulas and Expressions
        18. To-Do List
        19. Escape Sequence for Special Characters
      5. Programming Interactively with Jupyter Notebook Within VS Code
      6. Run Python Programs Outside IDE
      7. Make the Python Program File Executable
      8. Errors in Programs
    8. 1.7 Essentials of Problem Solving and Software Development
      1. Design Algorithms to Solve Problems
      2. Phases of Software System Development
        1. Phase 1. Understand the Project
        2. Phase 2. Analyze the Requirements to Identify Computer-Solvable Problems and Tasks
        3. Phase 3. Design the System
        4. Phase 4. Implement the System
        5. Phase 5. Test the System
        6. Phase 6. Maintain the System
    9. 1.8 Manage Your Working Files for Software Development Projects
      1. Set Up Git on Your Computer and Version-Control Locally
      2. Set Up an Account on GitHub and Version-Control with Remote Repositories
    10. Chapter Summary
    11. Exercises
    12. Projects
  6. Chapter 2 Essential Building Blocks of Computer Programs
    1. Learning Objectives
    2. 2.1 Primary Constructs of Computer Programs in Python
      1. Vocabulary of the Programming Language
        1. Rules of Naming Identifiers
        2. Python Naming Conventions
        3. Names with Leading and/or Trailing Underscores
        4. Rules of Scope Resolution for Identifiers
      2. Simple Data Types
        1. Signed Integers (int)
        2. Float (float)
        3. Boolean (bool)
        4. Complex (complex)
      3. Compound Data Types
        1. String (str)
        2. List
        3. Tuple
        4. Set
        5. Dictionary
        6. Object
      4. Variables and Constants
        1. Variables
        2. Built-In Constants
      5. Operators
        1. Arithmetic Operators
        2. Comparison Operators
        3. Logical Operators
        4. Bitwise Operators
        5. Assignment Operators
        6. Identity Operators
        7. Sequence Operators
        8. Membership Operator
      6. Built-In Functions
      7. Expressions
    3. 2.2 Higher-Level Constructs of Python Programs
      1. Structure of Python Programs
      2. Documentation and Comments
      3. Simple Statements
        1. Expression Statement
        2. Assignment Statement
        3. print Statement
        4. input Statement
        5. assert Statement
        6. pass Statement
        7. del Statement
        8. return Statement
        9. open Statement
        10. yield Statement
        11. raise Statement
        12. break Statement
        13. continue Statement
        14. import Statement
        15. global Statement
        16. nonlocal Statement
        17. help Statement
      4. Compound Statements
        1. Code Blocks
        2. Rules of Indentation
        3. Rules of Spacing
        4. if Statement
        5. if-else Statement
        6. if-elif Statement
        7. if-elif-else Statement
        8. while Statement
        9. for Statement
        10. def Statement
        11. class Statement
        12. try-except Statement
        13. with Statement
    4. Chapter Summary
    5. Exercises
    6. Projects
  7. Chapter 3 Flow Control of Statements
    1. Learning Objectives
    2. 3.1 Selective with the if Statement
    3. 3.2 Single-branch selective with if Statement
    4. 3.3 Multiple-Branch Selective with if-elif-… and if-elif-…-else Statements
    5. 3.4 Iterate with for Statement
      1. Using break and continue Statements and an else Clause Within Loops
      2. Common Coding Mistakes with the for Loop
    6. 3.5 Iterate with the while Statement
      1. Common Coding Mistakes with a while Loop
    7. 3.6 Iterate with for Versus while
    8. Chapter Summary
    9. Exercises
    10. Projects
  8. Chapter 4 Handle Errors and Exceptions in Programs
    1. Learning Objectives
    2. 4.1 Errors in Your Programs
      1. Exception
      2. ArithmeticError
      3. OverflowError
      4. ZeroDivisionError
      5. FloatingPointError
      6. AssertionError
      7. AttributeError
      8. BufferError
      9. EOFError
      10. GeneratorExit
      11. ImportError
      12. IndexError
      13. KeyError
      14. KeyboardInterrupt
      15. MemoryError
      16. ModuleNotFoundError
      17. NameError
      18. NotImplementedError
      19. OSError
      20. BlockingIOError
      21. ChildProcessError
      22. ConnectionError
      23. BrokenPipeError
      24. ConnectionAbortedError
      25. ConnectionRefusedError
      26. ConnectionResetError
      27. FileExistsError
      28. FileNotFoundError
      29. IsADirectoryError
      30. NotADirectoryError
      31. PermissionError
      32. ProcessLookupError
      33. TimeoutError
      34. RecursionError
      35. ReferenceError
      36. RuntimeError
      37. StopIteration
      38. StopAsyncIteration
      39. SyntaxError
      40. IndentationError
      41. TabError
      42. SystemError
      43. SystemExit
      44. TypeError
      45. UnboundLocalError
      46. UnicodeError
      47. UnicodeEncodeError
      48. UnicodeDecodeError
      49. UnicodeTranslateError
      50. ValueError
    3. 4.2 Handling Runtime Errors and Exceptions
    4. Chapter Summary
    5. Exercises
  9. Chapter 5 Use Sequences, Sets, Dictionaries, and Text Files
    1. Learning Objectives
    2. 5.1 Strings
      1. Methods of Built-In Class str
      2. Built-In Functions and Operators for Strings
      3. Constructing and Formatting Strings
      4. Regular Expressions
    3. 5.2 Lists
    4. 5.3 Tuples
    5. 5.4 Sets
    6. 5.5 Dictionaries
    7. 5.6 List, Set, and Dictionary Comprehension
      1. List Comprehension
      2. Set Comprehension
      3. Dictionary Comprehension
    8. 5.7 Text Files
      1. Opening and Closing a File
      2. Write or Append to a File
      3. Reading from a File
      4. Update Existing Content of a Text File
      5. Deleting Portion of a Text File
    9. Chapter Summary
    10. Exercises
    11. Projects
  10. Chapter 6 Define and Use Functions
    1. Learning Objectives
    2. 6.1 Defining and Using Functions in Python
    3. 6.2 Parameters and Arguments in Functions
    4. 6.3 Recursive Functions
    5. 6.4 Anonymous Functions: lambda Expressions
    6. 6.5 Special Functions: Mapping, Filtering, and Reducing
      1. Mapping
      2. Filtering
      3. Reducing
    7. 6.6 Generators: Turning a Function into a Generator of Iterables
    8. 6.7 Closures: Turning a Function into a Closure
    9. 6.8 Decorators: Using Function as a Decorator in Python
    10. 6.9 Properties of Functions
    11. Chapter Summary
    12. Exercises
    13. Projects
  11. Chapter 7 Object-Oriented Programming with Python
    1. Learning Objectives
    2. 7.1 Introduction to Object-Oriented Programming (OOP)
      1. Abstraction
      2. Information Hiding or Data Encapsulation
      3. Inheritance
    3. 7.2 Defining and Using Classes in Python
      1. Inheritance: Subclass and Superclass
      2. Public, Private, and Protected Members of a Class
      3. Class Methods
      4. Static Methods
      5. Class Attributes
    4. 7.3 Advanced Topics in OOP with Python
      1. Dunder Methods in Class Definition
      2. Using Class as Decorator
      3. Built-In Property() Function and Property Decorator
      4. Creating a New Class Dynamically and Modify a Defined Class or Instance
      5. Keeping Objects in Permanent Storage
    5. Chapter Summary
    6. Exercises
    7. Project
  12. Chapter 8 Modules and Packages
    1. Learning Objectives
    2. 8.1 Creating Modules and Packages
    3. 8.2 Using Modules and Packages
    4. 8.3 Install and Learn About Modules Developed by Others
    5. 8.4 Module for Generating Random Numbers
      1. Functions for Bookkeeping
      2. Functions for Generating Random Integers
      3. Functions for Randomly Generating Float Numbers
      4. Functions for Randomly Selected Item(s) from Sequences
    6. 8.5 Module for Mathematical Operations
    7. 8.6 Modules for Time, Date, and Calendar
      1. The Datetime Module
      2. The Time Module
      3. The Calendar Module
    8. 8.7 Modules for Data Representation and Exchange
    9. 8.8 Modules for Interfacing Operating Systems and Python Interpreter
      1. OS Module for Interacting with the Operating System
      2. The path Submodule from os for Manipulating File Paths
      3. The sys Module for Interaction Between the Python and Python Interpreter or Python Virtual Machine (PVM)
    10. 8.9 Module for Logging Events During Program Runtime
    11. 8.10 Modules for Playing and Manipulating Audio and Video Files
      1. winsound
      2. PyGame
    12. 8.11 Modules for Creating and Manipulating Graphics and Images
      1. Create Graphics with Tkinter
      2. Manipulate Images with Pillow
    13. 8.12 Modules for Data Analytics
    14. Chapter Summary
    15. Exercises
    16. Projects
  13. Chapter 9 Develop GUI-Based Applications
    1. Learning Objectives
    2. 9.1 Terminal-Based Applications Versus GUI-Based Applications
    3. 9.2 Designing and Developing GUI-Based Applications in Python
      1. Tkinter Module
      2. tkinter.ttk—Tk-Themed Widgets
    4. Chapter Summary
    5. Exercises
    6. Projects

Contents

Chapter 1 Introduction

Learning Objectives

1.1 A Brief History of Computers

1.2 Fundamentals of Computing and Modern Computers

Number Systems and the Foundation of Computing

Computability and Computational Complexity

The Construction of Modern Computers

Analog Computers

Digital Computers

Mechanic-Based Components

Vacuum Tube–Based Components

Transistors

Integrated Circuits and Very Large-Scale Integrated Circuits

1.3 Programming and Programming Languages

1.4 Python Programming Language

The Development and Implementation of Python

Advantages of Python

Resources for Python and Python Education

1.5 Getting Ready to Learn Programming in Python

Installing and Setting Up the Python Programming Environment

Installing Python

Setting Up a Virtual Environment for a Python Project

Installing Jupyter Notebook

Installing Visual Studio Code

Additional Tools Supporting Software Development in Python

Buildbot

Trac

Roundup

1.6 Getting a Taste of Programming with Python

Program Interactively with Python Interactive Shell

Program with VS Code IDE

Use Jupyter Notebook Within VS Code to Program Interactively

Write Documentation in Markdown

Headings

Paragraphs

New Lines

Italic, Bold, and Strikethrough Texts

Horizontal Rules

Keyboard Keys

Unordered Lists

Ordered Lists

Definition Lists

Links

Links to Internal Sections

Images

Blockquotes

Tables

Inline Program / Script Code

Code Block

Mathematical Formulas and Expressions

To-Do List

Escape Sequence for Special Characters

Programming Interactively with Jupyter Notebook Within VS Code

Run Python Programs Outside IDE

Make the Python Program File Executable

Errors in Programs

1.7 Essentials of Problem Solving and Software Development

Design Algorithms to Solve Problems

Phases of Software System Development

Phase 1. Understand the Project

Phase 2. Analyze the Requirements to Identify Computer-Solvable Problems and Tasks

Phase 3. Design the System

Phase 4. Implement the System

Phase 5. Test the System

Phase 6. Maintain the System

1.8 Manage Your Working Files for Software Development Projects

Set Up Git on Your Computer and Version-Control Locally

Set Up an Account on GitHub and Version-Control with Remote Repositories

Chapter Summary

Exercises

Projects

Chapter 2 Essential Building Blocks of Computer Programs

Learning Objectives

2.1 Primary Constructs of Computer Programs in Python

Vocabulary of the Programming Language

Rules of Naming Identifiers

Python Naming Conventions

Names with Leading and/or Trailing Underscores

Rules of Scope Resolution for Identifiers

Simple Data Types

Signed Integers (int)

Float (float)

Boolean (bool)

Complex (complex)

Compound Data Types

String (str)

List

Tuple

Set

Dictionary

Object

Variables and Constants

Variables

Built-In Constants

Operators

Arithmetic Operators

Comparison Operators

Logical Operators

Bitwise Operators

Assignment Operators

Identity Operators

Sequence Operators

Membership Operator

Built-In Functions

Expressions

2.2 Higher-Level Constructs of Python Programs

Structure of Python Programs

Documentation and Comments

Simple Statements

Expression Statement

Assignment Statement

print Statement

input Statement

assert Statement

pass Statement

del Statement

return Statement

open Statement

yield Statement

raise Statement

break Statement

continue Statement

import Statement

global Statement

nonlocal Statement

help Statement

Compound Statements

Code Blocks

Rules of Indentation

Rules of Spacing

if Statement

if-else Statement

if-elif Statement

if-elif-else Statement

while Statement

for Statement

def Statement

class Statement

try-except Statement

with Statement

Chapter Summary

Exercises

Projects

Chapter 3 Flow Control of Statements

Learning Objectives

3.1 Selective with the if Statement

3.2 Single-branch selective with if Statement

3.3 Multiple-Branch Selective with if-elif-… and if-elif-…-else Statements

3.4 Iterate with for Statement

Using break and continue Statements and an else Clause Within Loops

Common Coding Mistakes with the for Loop

3.5 Iterate with the while Statement

Common Coding Mistakes with a while Loop

3.6 Iterate with for Versus while

Chapter Summary

Exercises

Projects

Chapter 4 Handle Errors and Exceptions in Programs

Learning Objectives

4.1 Errors in Your Programs

Exception

ArithmeticError

OverflowError

ZeroDivisionError

FloatingPointError

AssertionError

AttributeError

BufferError

EOFError

GeneratorExit

ImportError

IndexError

KeyError

KeyboardInterrupt

MemoryError

ModuleNotFoundError

NameError

NotImplementedError

OSError

BlockingIOError

ChildProcessError

ConnectionError

BrokenPipeError

ConnectionAbortedError

ConnectionRefusedError

ConnectionResetError

FileExistsError

FileNotFoundError

IsADirectoryError

NotADirectoryError

PermissionError

ProcessLookupError

TimeoutError

RecursionError

ReferenceError

RuntimeError

StopIteration

StopAsyncIteration

SyntaxError

IndentationError

TabError

SystemError

SystemExit

TypeError

UnboundLocalError

UnicodeError

UnicodeEncodeError

UnicodeDecodeError

UnicodeTranslateError

ValueError

4.2 Handling Runtime Errors and Exceptions

Chapter Summary

Exercises

Chapter 5 Use Sequences, Sets, Dictionaries, and Text Files

Learning Objectives

5.1 Strings

Methods of Built-In Class str

Built-In Functions and Operators for Strings

Constructing and Formatting Strings

Regular Expressions

5.2 Lists

5.3 Tuples

5.4 Sets

5.5 Dictionaries

5.6 List, Set, and Dictionary Comprehension

List Comprehension

Set Comprehension

Dictionary Comprehension

5.7 Text Files

Opening and Closing a File

Write or Append to a File

Reading from a File

Update Existing Content of a Text File

Deleting Portion of a Text File

Chapter Summary

Exercises

Projects

Chapter 6 Define and Use Functions

Learning Objectives

6.1 Defining and Using Functions in Python

6.2 Parameters and Arguments in Functions

6.3 Recursive Functions

6.4 Anonymous Functions: lambda Expressions

6.5 Special Functions: Mapping, Filtering, and Reducing

Mapping

Filtering

Reducing

6.6 Generators: Turning a Function into a Generator of Iterables

6.7 Closures: Turning a Function into a Closure

6.8 Decorators: Using Function as a Decorator in Python

6.9 Properties of Functions

Chapter Summary

Exercises

Projects

Chapter 7 Object-Oriented Programming with Python

Learning Objectives

7.1 Introduction to Object-Oriented Programming (OOP)

Abstraction

Information Hiding or Data Encapsulation

Inheritance

7.2 Defining and Using Classes in Python

Inheritance: Subclass and Superclass

Public, Private, and Protected Members of a Class

Class Methods

Static Methods

Class Attributes

7.3 Advanced Topics in OOP with Python

Dunder Methods in Class Definition

Using Class as Decorator

Built-In Property() Function and Property Decorator

Creating a New Class Dynamically and Modify a Defined Class or Instance

Keeping Objects in Permanent Storage

Chapter Summary

Exercises

Project

Chapter 8 Modules and Packages

Learning Objectives

8.1 Creating Modules and Packages

8.2 Using Modules and Packages

8.3 Install and Learn About Modules Developed by Others

8.4 Module for Generating Random Numbers

Functions for Bookkeeping

Functions for Generating Random Integers

Functions for Randomly Generating Float Numbers

Functions for Randomly Selected Item(s) from Sequences

8.5 Module for Mathematical Operations

8.6 Modules for Time, Date, and Calendar

The Datetime Module

The Time Module

The Calendar Module

8.7 Modules for Data Representation and Exchange

8.8 Modules for Interfacing Operating Systems and Python Interpreter

OS Module for Interacting with the Operating System

The path Submodule from os for Manipulating File Paths

The sys Module for Interaction Between the Python and Python Interpreter or Python Virtual Machine (PVM)

8.9 Module for Logging Events During Program Runtime

8.10 Modules for Playing and Manipulating Audio and Video Files

winsound

PyGame

8.11 Modules for Creating and Manipulating Graphics and Images

Create Graphics with Tkinter

Manipulate Images with Pillow

8.12 Modules for Data Analytics

Chapter Summary

Exercises

Projects

Chapter 9 Develop GUI-Based Applications

Learning Objectives

9.1 Terminal-Based Applications Versus GUI-Based Applications

9.2 Designing and Developing GUI-Based Applications in Python

Tkinter Module

tkinter.ttk—Tk-Themed Widgets

Chapter Summary

Exercises

Projects

Annotate

Next Chapter
Chapter 1. Introduction
PreviousNext
Powered by Manifold Scholarship. Learn more at
Opens in new tab or windowmanifoldapp.org