Table of
Contents
Learn to Program with Python
Chapter 1---Where Do I Begin?
Where Do We Begin
Programming the Easy Way
Planning a Program is Like Planning a House
We Receive a Call from our 'client'
We Meet with Our Client
The Systems Development Life Cycle (SDLC)
Phase 1: The Preliminary Investigation
Phase 2: Analysis Phase
Phase 3: Design Phase
Output Design
Input Design
Processing Design
Phase 4: Development Phase
Phase 5: Implementation Phase
Phase 6: Audit and Maintenance Phase
Where To From Here?
Chapter 2--- Getting Comfortable With Python
Installing Python
Let's talk about IDLE
Getting Comfortable with Python
Writing Our First Python program Using Notepad (or Notepad++)
Create the Source File with a file name extension of .py
Execute the Python Program
Elements of a Python program
Program Comments
The print() Function
The input() Function
Chapter 3---Data
Computer Data
Variables
Our first variable: The Global Variable
Creating/Initializing a Variable
Rules For Naming Variables
Pseudo Constants
Python Data Types
int and float
bool
Strings
Operations on Data
Mathematical Operations
Order of Operations
Comparison Operators
Boolean Operators
Chapter 4---Selection Structures
Selection Structures
Getting Input Into Your Program
The Sequence Structure---Falling Rock
The Python Selection Structure---the If Statement
The If…Else Statement
The elif Clause
Chapter 5---Loops
The For Loop
The Range() Function
Variations on the For Loop Theme
The While Loop
Break and Continue Statements in For and While Loops
Chapter 6---Creating Your Own Functions
Creating your own Functions
A Function defined with a Single Mandatory Parameter
A Function Defined with two or more Mandatory parameters
Calling a Function Using Named Arguments
A Function Defined with Optional Parameters
A Function that returns a value
Passing Variables As Arguments to a Function
Variables Defined within Functions are Local Variables
Placing Functions in an External Module
Chapter 7---Lists and Strings
Lists
Common Errors when working with Lists
Updating Items in a List using its Index
Displaying Items in a List the Fast Way
Displaying Items in a List using Negative Indices
Creating a List of Strings
Creating a List with mixed Data Types
Creating a List of Lists
Using the append() method to add one item to a List
Adding multiple items to a List using the extend() method
Adding multiple Items to a List using List Concatenation
Deleting an Item in a List using the Delete (del) Statement
Deleting an Item in a List using the remove() method
Using the in operator to determine if an item exists in a List
Deleting Multiple Items in a List
Slicing Lists
Using Slices to delete items in a List
Using a Slice to display a portion of a List
Updating Multiple Items in a List using a Slice
Inserting Items in a List using a Slice
Deleting Items in a List using a Slice
Creating a new List using a Slice
Sorting Items in a List
Reversing Items in a List
Strings
Strings are made up of characters
Slicing Strings
Using the in operator to determine if a character exists in a String
The replace() method of the String object
String Concatenation
The upper() method of the String object
The lower() method of the String object
The capitalize() method of the String object
The title() method of the String object
The len() function
Chapter 8---Errors and Exception Handling
Errors and Exception Handling
Common Beginner Errors
Python Interpreter Errors
Runtime Errors
Dealing With Errors/Exceptions in Your Program
Strategies for dealing with Exceptions
Basic Exception Handling
Try...Except Block
Generic Except Block
Try...Except...Finally Block