Mega Code Archive

 
Categories / Python / Function
 

Give the parameters in the function default values

def hello_3(greeting='Hello', name='world'):     print '%s, %s!' % (greeting, name) hello_3() hello_3('Greetings') hello_3('Greetings', 'universe') hello_3(name='Gumby') def hello_4(name, greeting='Hello', punctuation='!'):     print '%s, %s%s' % (greeting, name, punctuation) hello_4('Mars') hello_4('Mars', 'Hi') hello_4('Mars', 'Hi', '...') hello_4('Mars', punctuation='.') hello_4('Mars', greeting='It is a greeting!')