Wednesday, August 12, 2015

default value of argument in python when no argument given at all: arg1 = new

def happyBirthday(FirstName="FN", LastName="LN"):
    print("Happy Birthday, dear " + FirstName + " " + LastName + ".")
   
happyBirthday()
  
Will print: Happy Birthday, dear FN LN.

happyBirthday("FN1"): will print Will print: Happy Birthday, dear FN1 LN.
happyBirthday("FN1", "LN1"): will print Will print: Happy Birthday, dear FN1 LN1.

No comments:

Post a Comment