Python program to call a function using keyword argument

Here, we will write a Python program to call a function using keyword argument which allows us to change the order of arguments. By Shivang Yadav Last updated : January 05, 2024

Python function is a block of code which does a specific operation and can be called from anywhere in the code. Also, function accepts values i.e. argument to work upto.

Python also supports keyword Argument. This allows the programmer to change position on passing arguments. This is done using keyword argument.

Program to call a function using keyword augment

def show(id="<no id>",name="<no name>"):
    print("Your id is :",id,"and your name is :",name)

show(12,"deepak")
show(name = "priya",id = 34)

Output

The output of the above program is:

Your id is : 12 and your name is : deepak
Your id is : 34 and your name is : priya

To understand the above program, you should have the basic knowledge of the following Python topics:

Python Basic Programs »


Related Programs

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.