Introduction to Python Programming

Beginning 4 days

In this course you will learn to

  • Master the fundamentals of writing Python scripts
  • Learn core Python scripting elements such as variables and flow control structures
  • Discover how to work with lists and sequence data
  • Write Python functions to facilitate code reuse
  • Use Python to read and write files
  • Make code robust by handling errors and exceptions properly
  • Work with the Python standard library
  • Explore Python's object-oriented features
  • Search text using regular expressions

Training materials

All Python training students will receive comprehensive courseware.

Suggested attendees

Students who use the operating system (Linux, Unix, Windows, Solaris, macOS, etc.) on which they will be running Python and at least one other programming language is desirable.

Course Outline

  • Overview of Python
    • What is Python?
    • Interpreted languages
    • Advantages and disadvantages
    • Downloading and installing
    • Which version of Python
    • Where to find documentation
  • The Python environment
    • Structure of a Python script
    • Using the interpreter interactively
    • Running standalone scripts under Unix and Windows
  • Getting started
    • Using variables
    • String types: normal, raw and Unicode
    • String operators and expressions
    • Math operators and expressions
    • Writing to the screen
    • Command line parameters
    • Reading from the keyboard
  • Flow control
    • About flow control
    • Indenting is significant
    • The if and elif statements
    • while loops
    • Using lists
    • Using the for statement
    • The range() function
  • Array types
    • List operations
    • List methods
    • Strings are special kinds of lists
    • Tuples
  • Working with files
    • Text file I/O overview
    • Opening a text file
    • Reading text files
    • Raw (binary) data
    • Writing to a text file
  • Dictionaries and sets
    • Dictionary overview
    • Creating dictionaries
    • Dictionary functions
    • Fetching keys or values
    • Testing for existence of elements
    • Deleting elements
    • Sets And frozen sets
  • Functions
    • Syntax of function definition
    • Formal parameters
    • Global vs. local variables
    • Passing parameters and returning values
  • Sorting
    • The sorted() function
    • Alternate keys
    • Multiple keys
    • Lambda functions
  • Errors and exception handling
    • Dealing with syntax errors
    • Exceptions
    • Handling exceptions with try/except
    • Cleaning up with finally
  • Modules and packages
    • What is a module?
    • The import statement
    • Function aliases
    • Packages
  • Regular expressions
    • RE Objects
    • Pattern matching
    • Parsing data
    • Subexpressions
    • Complex substitutions
    • RE tips and tricks
  • Highlights of the standard library
    • Working with the operating system
    • Grabbing web pages
    • Sending email
    • math and random
    • Accessing dates and times with datetime
    • Working with compressed files
  • An introduction to Python classes
    • About o-o programming
    • Defining classes
    • Constructors
    • Instance methods
    • Instance data
    • Class methods and data
    • Destructors

  • Any Windows, Linux or macOS operating system
  • Python 3.x installed (Anaconda bundle recommended)
  • An IDE with Python support (PyCharm Community Edition is an excellent free option, but there are several other good ones)