

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Keyword arguments in Python
Keyword arguments are related to the function calls. When you use keyword arguments in a function call, the caller identifies the arguments by the parameter name.
This allows you to skip arguments or place them out of order because the Python interpreter is able to use the keywords provided to match the values with parameters. You can also make keyword calls to the printme() function in the following ways −
Example
#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme( str = "My string")
Output
When the above code is executed, it produces the following result −
My string
The following example gives more clear picture. Note that the order of parameters does not matter.
Example
#!/usr/bin/python # Function definition is here def printinfo( name, age ): "This prints a passed info into this function" print "Name: ", name print "Age ", age return; # Now you can call printinfo function printinfo( age=50, name="miki" )
Output
When the above code is executed, it produces the following result −
Name: miki Age 50
- Related Questions & Answers
- Python Pandas - Display the keyword arguments applied on the given BusinessDay object
- Python Pandas - Display the keyword arguments applied on the given BusinessHour object
- Python Pandas - Display the keyword arguments applied on the given CustomBusinessDay object
- Python Pandas - Display the keyword arguments applied on the given CustomBusinessHour object
- Required arguments in Python
- Default arguments in Python
- Variable-length arguments in Python
- Command Line Arguments in Python
- Finally keyword in Python
- Global keyword in Python
- assert keyword in Python
- What are default arguments in python?
- Packing and Unpacking Arguments in Python?
- Global keyword in Python program
- Command Line and Variable Arguments in Python?
Advertisements