Course Description
This four day course leads the student from the basics of writing and running Python scripts to more advanced features such as file operations, regular expressions, working with binary data, and using the extensive functionality of Python modules. Extra emphasis is placed on features unique to Python, such as tuples, array slices, and output formatting. This is a hands-on programming class. All concepts are reinforced by informal practice during the lecture followed by graduated lab exercises. Python Programming is a practical introduction to a working programming language, not an academic overview of syntax and grammar. Students will immediately be able to use Python to complete tasks in the real world.
Topics include:
- language components
- the Python environment
- using variables
- strings
- control flow constructs
- array types
- working with files
- dictionaries & sets
- functions
- sorting
- errors & exception handling
- using modules
- regular expressions
- using the Standard Library
- introduction to Python classes & objects
The course is supplemented with many hands on labs using either Linux or Windows.
Pre-requisites
Students should have some experience with at least one programming language, such as C, C++, Java, Perl, Ruby, VB or anything equivalent.
Who is this course for?
For Software Developers, System Administrators, Software Testers, and Users who need to work with with the Python programming language.
Further Training
After some further on-the-job experience with the Python language, we recommend students attend our
Python 3 Programming Advanced course to gain higher-level skills in the usage of Python.
Course content
An Overview of Python
The birth of Python
About interpreted languages
Advantages vs Disadvantages of Python
How to get Python
Which version of Python
The end of Python 2
Getting Help
The Python Environment
If the interpreter is not in your PATH
Using the interpreter
Trying out a few commands
Running Python scripts
Using pydoc
Python editors and IDEs
Getting Started
Keywords and Builtins
Variable typing
Strings
Single-delimited string literals
Triple-delimited string literals
Raw string literals
Unicode characters
String operators and methods
String methods
Numeric literals
Math operators and expressions
Converting among types
Writing to the screen
String formatting
Legacy string formatting
Command line parameters
Reading from the keyboard
Flow Control
What’s with the white space ?
if and elif
Conditional expressions
Relational operators
Boolean operators
while loops
Alternate ways to exit a loop
Array Types
Lists
Indexing and slicing
Iterating through a sequence
Tuples
Iterable unpacking
Nested sequences
Functions for all sequences
Using enumerate()
Operators and keywords for sequences
The range() function
List comprehensions
Generator expressions
Working with Files
Opening a text file
The with block
Reading a text file
Writing to a text file
Dictionaries and Sets
When to use dictionaries
Creating dictionaries
Getting dictionary values
Iterating through a dictionary
Reading file data into a dictionary
Counting with dictionaries
About sets
Creating sets
Working with sets
Functions
Returning values from a function
Function parameters
Variable scope
Sorting
The sorted() function
Custom sort keys
Lambda functions
Sorting nested data
Sorting dictionaries
Sorting in reverse
Sorting lists in place
Errors and Exception Handling
Exceptions
Handling exceptions with try
Handling multiple exceptions
Handling generic exceptions
Ignoring exceptions
Using else
Cleaning up with finally
Using Modules
Creating modules
The import statement
Where did _pycache_ come from ?
Module search path
Packages
Example
Module aliases
Regular Expressions
RE syntax overview
Finding matches
RE objects
Compilation flags
Groups
Special groups
Replacing text
Replacing with a callback
Splitting a string
Using the Standard Library
Interpreter information
STDIO
Launching external programs
Paths, directories, and filenames
Walking directory trees
Grabbing data from the web
Sending email
Math functions
Random values
Dates and times
Zipped archives
Introduction to Python Classes
Defining classes
Constructors
Instance methods
Properties
Class methods and data
Static methods
Private methods
Inheritance
Untangling the nomenclature
String Formatting
Parameter selectors
Data types
Field widths
Alignment
Fill characters
Signed numbers
Parameter attributes
Formatting dates
Run-time formatting