Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5dd64c7

Browse files
author
Amogh Singhal
authored
Update Python_Programming_Quiz.md
1 parent c5b8a51 commit 5dd64c7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎Python_Programming_Quiz.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,34 @@ isPalindrome('CCC.')
483483
isPalindrome('CCC')
484484
# prints True
485485
```
486+
487+
#### 30. What do you mean by `*args` and `**kwargs`?
488+
489+
In cases when we don’t know how many arguments will be passed to a function, like when we want to pass a list or a tuple of values, we use `*args`.
490+
```
491+
def func(*args):
492+
for i in args:
493+
print(i)
494+
495+
496+
func(3,2,1,4,7)
497+
3
498+
2
499+
1
500+
4
501+
7
502+
```
503+
504+
`**kwargs` takes keyword arguments when we don’t know how many there will be.
505+
506+
```
507+
def func(**kwargs):
508+
for i in kwargs:
509+
print(i,kwargs[i])
510+
511+
512+
func(a=1,b=2,c=7)
513+
a.1
514+
b.2
515+
c.7
516+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /