Contents

Python 3 for Cmput 455 Bootcamp/Refresher

Since Python is currently a popular teaching language, and this is a fourth year course, I expect most students to be familiar with many of the concepts discussed here. Please review this page as needed for coursework, and catch up on any concepts that do not look familiar.

Basics

Math, bit-fiddling

Sequences and Ranges

Lists

Lists are one popular type of sequence.

Python Libraries

Measuring Time

To measure how much time some piece of code has used, time.process_time() is a simple way which is available in Python 3.3 and up. See the Python Documentation of the time module and an example of the use in the Tic Tac Toe solver code.

A different, more complex but also more convenient approach is to use the signal module. Example: initialize with

signal.signal(signal.SIGALRM, handler)

Then use it to throw an exception at timeout within a try - except block:

signal.alarm(timelimit)

See the documentation for details on signal, and which parts of that library are supported in which python versions. As always, if it is part of coursework, then make sure it works on the undergrad machines before using it.

Classes and Objects in Python

Python Specialties