Articles → Python → Default function arguments in python

Default function arguments in python






What is default function arguments?




# this is the function definition
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")





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") 





Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250