--Originally published at Codebuster
So as said before, functions are pretty useful, but what if we need one that does not come prepackaged? or even better, what if we want to create one our own, its fairly simple.
The first thing we need to do to start wrtting a function is define it, using “def” a space and the name you want to assign to your function. You want to be careful how you name your function, so it doesnt get mixed up with other values,
Next you should write the parameters for your function between parentheses so like this:
def function1 (parameter):
here you would write what you want your function should do
Here is an actual function to calculate the volume of a figure
Which would give back:
That’s as easy as it is, enjoy!