Python Pushups¶
These are a couple exercises to kick you off with Python
Task 1: Explore Errors¶
Create a new directory in your working dir for the class:
$ mkdir session01 $ cd session01
Add a new file to it called
break_me.py
In the
break_me.py
file write four simple Python functions:- Each function, when called, should cause an exception to happen
- Each function should result in one of the four most common exceptions you’ll find.
- for review:
NameError
,TypeError
,SyntaxError
,AttributeError
(hint – the interpreter will quit when it hits a Exception – so you can comment out all but the one you are testing at the moment)
- Use the Python standard library reference on Built In Exceptions as a reference
Task 2: Puzzles¶
To get a bit of exercise solving some puzzles with Python, work on the Python exercises at “Coding Bat”: http://codingbat.com/python
There are 8 sets of puzzles. Do as many as you can, but try to get to at least the “Warmups”.