Default argument

Default Argument

In Python the default argument is an argument that takes a default value if no value is provided in the function call. The following example uses default arguments, that prints default salary when no argument is passed.

Example:

def printinfo( name, salary = 3500):
	print (“Name: “, name)
	print (“Salary: “, salary)
	return
printinfo(“Mani”)

Output:

Name: Mani

Salary: 3500

When the above code is changed as print info(“Ram”,2000) it produces the following output:

Output:

Name: Ram

Salary: 2000

In the above code, the value 2000 is passed to the argument salary, the default value already assigned for salary is simply ignored.

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz