Table of content

What does ** mean in python?

In python, double-asterisk(**) can be used as an exponentiation operator or to send multiple keyword arguments to a function.

Using ** as an exponentiation operator

In python, ** is an exponentiation operator for numeric data types. Consider two operands a and b. a**b means a raised to the power of b. In mathematics, we see this expression asexponent-operator-python

For example, 2 raised to the power of 5 = 2**5 gives the output as 32.




Using ** to pass multiple keyword arguments to a function

A function is a block of code that performs a specific task. It increases the code reusability and provides better modularity for an application.

A **kwargs allows us to pass variable length keyword arguments to a function. Keyword argument is nothing but a dictionary, that maps each keyword to a value.

def my_function(**kwarg_1):

my_function( first = "one", second = "two", third = "three")


{'first': 'one', 'second': 'two', 'third': 'three'}
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions