''' An example of exception handling in Python. Read through it carefully and figure out what it will do when run from the command line with 1.0 as its argument, and again with 0.0 as argument. ''' import sys def reciprocal(x): try: result = 1/x except ZeroDivisionError: print "..Whoopsy daisey! Something wrong." print "..Returning default" result = 10.0**99 return result print "\nAnd (drum roll, please) the answer is..." answer = reciprocal(float(sys.argv[1])) print answer, "!\n"