functions.org
changeset 113 6388eacf7502
parent 110 c1099ad60539
child 118 2f247bcfae8b
equal deleted inserted replaced
112:7de6be45182e 113:6388eacf7502
    46     tutorial on strings. Let's look at how to write them here. 
    46     tutorial on strings. Let's look at how to write them here. 
    47 
    47 
    48     Let us add a simple doc string to our welcome function. 
    48     Let us add a simple doc string to our welcome function. 
    49 
    49 
    50         def welcome(name):
    50         def welcome(name):
    51 	    """ Prints a hello message to a person, given a name. """
    51 	    """ Prints a hello message to a person,
       
    52 	        given a name. """
    52 	    print "Hello", name 
    53 	    print "Hello", name 
    53     
    54     
    54     Notice that the doc string uses triple quotes. If the doc-string
    55     Notice that the doc string uses triple quotes. If the doc-string
    55     exceeded one line, we could have used new line characters in
    56     exceeded one line, we could have used new line characters in
    56     it. Also, as expected the doc-string is indented as is required
    57     it. Also, as expected the doc-string is indented as is required
    57     for anything within a block. 
    58     for anything within a block. 
    58 
    59 
    59     We shall now look at default arguments. 
    60     We shall now look at default arguments. 
    60     [show slide with examples of functions with default arguments]
    61     [show slide with examples of functions with default arguments]
    61     The strip function has been used in two different ways in the
    62     The split function has been used in two different ways in the
    62     previous tutorials - one for splitting on spaces and the other for
    63     previous tutorials - one for splitting on spaces and the other for
    63     splitting on commas. 
    64     splitting on commas. 
    64 
    65 
    65     The function split is being called with no arguments and one
    66     The function split is being called with no arguments and one
    66     argument, respectively. In the first case, white space is being
    67     argument, respectively. In the first case, white space is being