Python Built-in Functions Parameters

In this article we want to learn about Python Built-in Functions Parameters, so Python is powerful programming language, and one of the best reason for this is having a lot of built in functions, these functions are pre defined and available in Python interpreter, and they can be used to perform different task.

 

 

Python Built-in Functions Parameters

One of the key features of Python is builtin functions, and we can use parameters on them. these parameters allows you to customize the behavior of a function. in this article we want to talk about different types of parameters that are used in Python builtin functions.

 

 

Positional Parameters

this is the most common type of parameter used in Python builtin functions. these parameters are identified by their position in the function call, and their values are determined by the order in which they are provided. for example  let’s talk about builtin function print(). it accepts one or more positional parameters, and they are the values that will be printed in the console:

 

 

Run the code and this will be the result

Python Built-in Functions Parameters
Python Built-in Functions Parameters

 

 

Keyword Parameters

Another type of parameter in Python builtin functions is keyword parameter. these parameters are identified by their name, and they are specified in the function call. Keyword parameters provides a way to specify optional arguments.

In the above example pow() function is called with two positional parameters. these values are used to calculate the power of two numbers, but pow() function also accepts third, optional keyword parameter called mod, and that specifies the modulus to use in the calculation. 

 

You can use it like this

 

 

This will be the result

Python POW Function
Python POW Function

 

 

Default Parameters

Third type of parameter is Python builtin functions is the default parameter. default parameters provides a way to specify a default value for an optional argument, and that will be used if the argument is not provided in the function call. 

 

For example this is an example of Python range() builtin function, it generates a sequence of numbers:

In the above example range() function is called with one positional parameter. this tells the function to generate a sequence of numbers from 0 to 4. but the range() function also accepts two optional default parameters called start and step, which specify the starting value and the step size of the sequence.

 

 

This will be the result

Python Range Function
Python Range Function

 

 

Learn More

Leave a Comment