Give the parameters in the function default values : Function Default Argument : Buildin Function PYTHON examples


PYTHON examples » Buildin Function » Function Default Argument »

 

Give the parameters in the function default values


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!')

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Buildin Function
» Function Default Argument