Robotics & Artificial Intelligence

What are the various parameter passing techniques?

Python Functions

1 Like

Answer

Python supports the following parameter passing techniques:

  1. Fixed Length Arguments: These are the arguments defined in the function header. While calling the function, the values must be passed in the same order and number as specified in the function definition.
  2. Variable Length Arguments: Python allows a function to accept a variable number of arguments. There are two types:
    • *args: Stores the passed arguments in a tuple.
    • **kwargs: Stores the passed arguments in a dictionary.
  3. Default Arguments: These arguments have a default value assigned in the function definition. If no value is provided during the function call, the default value is used. Default arguments must appear after non-default arguments.

Answered By

1 Like


Related Questions