# HG changeset patch # User Puneeth Chaganti # Date 1272972158 -19800 # Node ID 2f247bcfae8b8a6ed1067dc30ef11b18e69f092f # Parent d3005da44457d32a32cada56432b66998f818ef6 Minor edits to functions script. diff -r d3005da44457 -r 2f247bcfae8b functions.org --- a/functions.org Thu Apr 29 17:58:22 2010 +0530 +++ b/functions.org Tue May 04 16:52:38 2010 +0530 @@ -89,16 +89,36 @@ welcome("Hi", name="Guido") welcome(name="Guido", greet="Hello") - Keyword arguments allow us to call functions by passing arguments + Keyword arguments allow us to call functions by passing arguments in any order and removes need to remember the order of arguments in the function definition. - + + Let us look at an example function. This will both act as a code + reading exercise and tell us an important point about return + values in python's functions. Pause the video for a while and + ponder about what this piece of code does. + [show slide?] -***** return values + def what( n ): + i = 1 + while i * i < n: + i += 1 + return i * i == n, i + + The function takes an integer as an argument and returns the + boolean True, and the square of the number, if it is a perfect + square OR the boolean False and the square root of the next + perfect square of the number. + Note that this function is returning two values. Functions in + Python are capable of returning any number of values. + ***** arguments are local to a function -***** availability library functions -***** code reading exercises? - + + Python follows the philosophy of batteries included. It comes + with a rich and versatile standard library with whole gamut of + functions. Do check out the standard library, before you sit down + to write functions of your own. + We come to the end of this tutorial on functions. In this tutorial we have learnt about functions in a greater detail. We looked at how to define functions, calling them, default and keyword