``````

In [1]:

def hello():
print('Hello')

``````
``````

In [2]:

hello()

``````
``````

Hello

``````
``````

In [3]:

return a + b

``````
``````

In [4]:

print(x)

``````
``````

7

``````
``````

In [5]:

print('a = ', a)
print('b = ', b)
print('c = ', c)
print('a + b + c = ', a + b + c)

``````
``````

In [6]:

``````
``````

a =  1
b =  10
c =  100
a + b + c =  111

``````
``````

In [7]:

# TypeError: print_add() missing 2 required positional arguments: 'b' and 'c'

``````
``````

In [8]:

# TypeError: print_add() takes 3 positional arguments but 4 were given

``````
``````

In [9]:

``````
``````

a =  1
b =  10
c =  100
a + b + c =  111

``````
``````

In [10]:

``````
``````

a =  1
b =  10
c =  100
a + b + c =  111

``````
``````

In [11]:

# SyntaxError: positional argument follows keyword argument

``````
``````

In [12]:

print('a = ', a)
print('b = ', b)
print('c = ', c)
print('a + b + c = ', a + b + c)

``````
``````

In [13]:

``````
``````

a =  1
b =  10
c =  100
a + b + c =  111

``````
``````

In [14]:

``````
``````

a =  1
b =  10
c =  200
a + b + c =  211

``````
``````

In [15]:

#     ...
# SyntaxError: non-default argument follows default argument

``````
``````

In [16]:

def func_args(*args):
print(args)

``````
``````

In [17]:

func_args(1, 10)

``````
``````

(1, 10)

``````
``````

In [18]:

func_args(1, 10, 100, 1000)

``````
``````

(1, 10, 100, 1000)

``````
``````

In [19]:

def func_kwargs(**kwargs):
print(kwargs)

``````
``````

In [20]:

func_kwargs(a=1, b=10)

``````
``````

{'a': 1, 'b': 10}

``````
``````

In [21]:

func_kwargs(c=1, b=10, d=1000, a=100)

``````
``````

{'c': 1, 'b': 10, 'd': 1000, 'a': 100}

``````
``````

In [22]:

print('a = ', a)
print('b = ', b)
print('c = ', c)
print('a + b + c = ', a + b + c)

``````
``````

In [23]:

l = [1, 10, 100]

``````
``````

a =  1
b =  10
c =  100
a + b + c =  111

``````
``````

In [24]:

l = [1, 10]

# TypeError: print_add() missing 1 required positional argument: 'c'

``````
``````

In [25]:

d = {'a': 1, 'b': 10, 'c': 100}

``````
``````

a =  1
b =  10
c =  100
a + b + c =  111

``````
``````

In [26]:

d = {'a': 1, 'b': 10, 'x': 100}

# TypeError: print_add() got an unexpected keyword argument 'x'

``````
``````

In [27]:

def func_return(a, b):
return a + b

``````
``````

In [28]:

x = func_return(3, 4)

print(x)
print(type(x))

``````
``````

7
<class 'int'>

``````
``````

In [29]:

x = func_return(0.3, 0.4)

print(x)
print(type(x))

``````
``````

0.7
<class 'float'>

``````
``````

In [30]:

def func_return_multi(a, b):
return a + b, a * b, a / b

``````
``````

In [31]:

x = func_return_multi(3, 4)

print(x)
print(type(x))

``````
``````

(7, 12, 0.75)
<class 'tuple'>

``````
``````

In [32]:

x, y, z = func_return_multi(3, 4)

print(x)
print(y)
print(z)

``````
``````

7
12
0.75

``````
``````

In [33]:

def func_return_multi_list(a, b):
return [a + b, a * b, a / b]

``````
``````

In [34]:

x = func_return_multi_list(3, 4)

print(x)
print(type(x))

``````
``````

[7, 12, 0.75]
<class 'list'>

``````
``````

In [35]:

x, y, z = func_return_multi_list(3, 4)

print(x)
print(y)
print(z)

``````
``````

7
12
0.75

``````