Quiz-6 functions

Screenshot (42)
can you please explain

1 Like

Hello @brindhubala30 ,

We have recieved your query.
This was a really nice question which you have asked.

Give us a couple of minutes & we will reach out with the solution for your query

Zeba Kainat| TA- Edyoda

1 Like

@brindhubala30
The syntax **kwargs in function definitions in python is used to pass a keyworded, variable-length argument list. We use the name kwargs with the double star. The reason is that the double star allows us to pass through keyword arguments (and any number of them).

A keyword argument is where you provide a name to the variable as you pass it into the function.
One can think of the kwargs as being a dictionary that maps each keyword to the value that we pass alongside it.

2 Likes

def display(**kwargs):
print(kwargs)
display(emp=“kelly”,salary = 9000)

output : {‘emp’: ‘kelly’, ‘salary’: 9000}

The above code mentioned will give you all the key & value .

and when we are using for loop it will iterate over the keys i.e. emp & salary , so only keys are printed not the value .

3 Likes