forked from Arunavaskar/learning-new
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_07.py
More file actions
39 lines (27 loc) · 884 Bytes
/
ex_07.py
File metadata and controls
39 lines (27 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def f1(a, b):
print(a, b)
# Обычные аргументы
def f2(a, *b):
print(a, b)
# Переменное число позиционных аргументов
def f3(a, **b):
print(a, b)
# Переменное число именованных аргументов
def f4(a, *b, **c):
print(a, b, c)
# Смешанный режим
def f5(a, b=2, c=3):
print(a, b, c)
# Аргументы со значениями по умолчанию
def f6(a, b=2, *c):
print(a, b, c)
# Переменное число позиционных аргументов и аргументов со значениями по умолчанию
f1(1, 2) # 1 2
f1(b=2, a=1) # 1 2
f2(1, 2, 3) # 1 (2, 3)
f3(1, x=2, y=3) # 1 {x: 2, y: 3}
f4(1, 2, 3, x=2, y=3) # 1 (2, 3) {x: 2, y: 3}
f5(1) # 1 2 3
f5(1, 4) # 1 4 3
f6(1) # 1 2 ()
f6(1, 3, 4) # 1 3 (4,)