Please send questions to st10@humboldt.edu .

*   random notes projected in Week 6 Lab, 2-21-07

*   remember that the scope of a variable 
    (the part(s) where it has meaning) is
    from where it is declared/created until
    the end of the "thing" it is created in;

    *   in a function? has scope of the rest of
        that function, ONLY

    *   in a file? has scope of the rest of that
        file, ONLY

    *   in a python session? has scope of the rest
        of that python session, ONLY

*   functions with side effects...

    ...for example, interactive input and/or interactive output

*   interactive output:
 
    print expr

    ...causes the VALUE of expr to be printed to the screen
    ...perhaps with a LITTLE format-tweaking...

    *   consider: a function MIGHT simply output something
        to the screen

    *   a function that takes a value and prints it between
        two lines of 20 asterisks

        *   void is what you use for the return type if a 
            function, in fact, returns NOTHING (NO return statement!)

# contract: name_in_lights: anything -> void
# purpose: print <thing> between two lines of 20 asterisks
# example: name_in_lights(13) would cause the following
#          to be printed to the screen (ignoring the comment marks!):
# ********************
# 13
# ********************

def name_in_lights(thing):
    print "********************"
    print thing
    print "********************"

*   what about a "hello, rain!" function?

    *   if a function takes NO parameters -- use
        void for THAT in its contract, too

# contract: greet_rain: void -> void
# purpose: greet the rain, printig to the screen
# example: if you call greet_rain(), the following
#          should be printed to the screen:
# hello, rain!

def greet_rain():
    print "hello, rain!"

*   add interactive input:

    Python function raw_input takes a string as its argument,
    and it prints that string to the screen, then waits for
    the user to type something followed by the ENTER key.

    What the user typed is returned as a string to the caller.

    # contract: raw_input: string -> string

*   what if we want a function that asks the user for his/her
    name, and then prints it between two rows of 20 asterisks?

# contract: show_name : void -> void
# purpose: asks the user for his/her name, and then prints it 
#          between two rows of 20 asterisks
# example: if I call show_name(), I will see a prompt:
#
# type your name:
#
# ...if I then type George, the following will be printed
# to the screen:
#
# ********************
# George
# ********************

def show_name():
    name = raw_input("type your name:")

    name_in_lights(name)