Articles → Python → Default Function Arguments In Python

Default Function Arguments In Python






Scenario




def PersonInformation(name, address):
    print ('person name is:', name)
    print ('person address is:', address)
    return




PersonInformation("gyan","India")




PersonInformation(address="india")







Default Function Argument




def PersonInformation(name='gyan', address=''):
    print ('person name is:', name)
    print ('person address is:', address)
    return




PersonInformation(address="india")



Output


Picture showing the output of default function argument in python



Using Default Function Arguments When The Number Of Parameters Is Not Known




def HelloWorld2(*allPeople):
    for x in allPeople:
        print ('Hello', x)




HelloWorld2("amit","sumit","Kiran")



Output


Picture showing the output of default function argument in python when number of parameters in unknown



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, April 18, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250