Functions

The def statement

     # Return the remainder of a/b
     def remainder(a,b):
        q = a/b
        r = a - q*b
        return r
     
     # Now use it
     a = remainder(42,5)       # a = 2
     

Returning multiple values

     def divide(a,b):
         q = a/b
         r = a - q*b
         return q,r
     
     x,y = divide(42,5)       # x = 8, y = 2
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 18
July 17, 2000, beazley@cs.uchicago.edu
>>>