# # sample program that uses a method that expects # one parameter, a string. # # written by e.bonakdarian oct 2009 # ######################################################## def greeting(new_name): # this method prints out a greeting using # the name sent to it. # print '---------------------------------' print 'Hello', new_name,'!' # this works - but print 'Hello %s!' % new_name # this is nicer (more control) print 'How nice of you to call on me :-)' print '---------------------------------\n' # some different ways of calling a function ... # using a string literal as argument to the function greeting("Levon") # using a variable as argument to the function name = "Detective Pempleton" greeting(name) # prompting for the argument to be passed to the functon name = raw_input('what is your name? ') greeting(name) # a final example showing string concatenation greeting('Dear ' + name)