Functions are defined using the def keyword followed by the function name, an argument list in parentheses, and a colon to start a new block. We use the return keyword to return a value form the function.
>>> def hello_world():
... print("Hello world")
...
>>> hello_world() # Calling the function from REPL Environment
Hello world
>>> def hello_world():
... print("Hello World")
... return
... print("This will not be executed")
...
>>> hello_world()
Hello World
>>>
Functions aren't required to explicitly return a value though. Perhaps they produce side effects. You can return early from a function by using the return keyword with no parameter. A return keyword without a parameter, or the implicit return at the end of a function, actually causes the function to return None, although remember that the REPL doesn't display None results, so we don't see them. By capturing the returned object into a named variable, we can test for None.
>>> def add(a,b):
... return a+b
...
>>> x=add(10,20) # calling add function and capturing result to x
>>> x
30
>>> def add(x,y):
... x+y
...
>>> sum=add(10,20)
>>> sum
>>> type(sum)
<class 'NoneType'>
>>> sum is None
True