Functions in Python are factories. Of course, this is true with any coding language and developers need these factories because it keeps them from writing code over and over. Anyway, functions are not something native to programming. It was in math before programming came on the scene. For instance, y = x^2 (y equals x squared) is the function of a parabola. When something is put in, something comes out, cause it's a factory.
Diving In
Let's dive in a study some code. It's all sort of self-explanatory if you look at it long enough. However, feel free to ask questions about it. I mean, sometimes things can get rough.
Diving In
Let's dive in a study some code. It's all sort of self-explanatory if you look at it long enough. However, feel free to ask questions about it. I mean, sometimes things can get rough.
Code:
def multiply_function(a, b):
print(a * b)
# Let's call the function.
multiply_function(5, 5)
""" This should print out 5 * 5 which equals 25. It does this because we put two
arguments in the function corresponding to a and b and the function multiplies them. """