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 f60fc7b

Browse files
Add demo for key-word function arguments.
1 parent 32042ac commit f60fc7b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎FunctionIntroduction/src/findprime.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ def arbitrary_list_arg_func_2(a, b, c, *args):
4040
print('*args: stands for list of optional arguments')
4141
print(a, b, c, args)
4242

43-
43+
def key_word_func_args(a, b, *args, **kargs):
44+
print('Key word function arguments are discussed in this function')
45+
print('a={}'.format(a))
46+
print('b={}'.format(b))
47+
print('arbitraty number of arguments as tuple = {}'.format(args))
48+
print('\nFollowing represents key-word arguments:')
49+
print('NOTE: key-word arguments are actually passed as dictionary to the function.')
50+
51+
for k in kargs:
52+
print('key = {} and value = {}'.format(k, kargs[k]))
4453

4554
def main():
4655
for n in range(1, 20):
@@ -54,5 +63,7 @@ def main():
5463
arbitrary_list_arg_func_1(1,2,3,4,5)
5564
print()
5665
arbitrary_list_arg_func_2(1, 2, 3, 4,5,6,7)
66+
print()
67+
key_word_func_args(3, 45, 1 , 2, 3, one = 1, two = 2, three = 3)
5768

5869
if __name__ == '__main__': main()

0 commit comments

Comments
(0)

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