In python, we start defining a function with "def" and end the function with "return".
A function of variable x is denoted as f(x). What this function does? Suppose, this function adds 2 to x. So, f(x)=x+2
Now, the code of this function will be:
def A_function (x):
return x + 2
After defining the function, you can use that for any variable and get result. Such as:
print A_function (2)
>>> 4
We could just write the code slightly differently, such as:
def A_function (x):
y = x + 2
return y
print A_function (2)
That would also give "4".
Now, we can even use this code:
def A_function (x):
x = x + 2
return x
print A_function (2)
That would also give 4. See, that the "x" beside return actually means (x+2), not x of "A_function(x)".