Articles → Python → Default function arguments in python

Default function arguments in python






What is default function arguments?




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




PersonInformation("gyan","India")




PersonInformation(address="india")








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




PersonInformation(address="india")




Picture showing the output of default function argument in python

Click to Enlarge


Using default function arguments when number of parameters is not known




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




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




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

Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250