Functions
Introduction into reusing code
By Rotary Viper Home
In python, functions are following this syntax: foo(argument(s))
We've been using functions throughout this tutorial. Some examples are print(), input(), tuple(), range() etc.
You give a function argument(s), it returns you an output

You can create functions by defining them.
The syntax is:
def foo(arguments):
...
return output

If you ran the code:
def addNumbers(num1, num2):
    return num1+num2

for i in range(4): print(addNumbers(i,i+1))
Python would output:
1
3
5
7
Not all functions need arguments. You can call functions without arguments.
The syntax is:
def foo():
...
return output

If you ran the code:
def pi():
    return 3.14

pi()
pi()*3
Python would output:
3.14
9.42
You can declare variables and functions inside functions.
These are called local variables and local functions, respectively.
For local variables:
If you ran the code:
def myFunction(x):
    num1 = x**3
    num2 = x**(1/2)
    return num1-num2

print(myFunction(4))
Python would output:
62.0