Introduction to Computer Programming with Python 9781998944095, 9781998944071, 9781998944088

This introduction to computer programming with Python begins with some of the basics of computing and programming before

131 59 4MB

English Pages 500 Year 2023

Report DMCA / Copyright

DOWNLOAD EPUB FILE

Table of contents :
Cover
Title Page
Copyright Page
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

Introduction to Computer Programming with Python
 9781998944095, 9781998944071, 9781998944088

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
Recommend Papers