Arguments/parameters are almost the same.
Here's a real snippet of code example for conways game of life rules:
def judge_cell(alive, neighbours):
"""
Encapsulates all conway's game rules
:parameter:
`alive` : bool
If cell is occupied or not
`neighbours` : int
Amount of neighbours
:return:
True : if alive
False : if dead
None : if not bool
Rules:
Occupied:
Death = 4 <= neighbours
Death = 1 >= neighbours
Not Occupied:
Birth = 4 == neighbours
"""
if alive is True:
if neighbours >= 4:
alive = False
elif neighbours <= 1:
alive = False
elif alive is False:
if neighbours == 4:
alive = True
else:
return None
return alive
state = True
neighbour_count = 4
judge_cell(state, neighbour_count)
Most of it is comments/documentation. But this is created to be used from anywhere, called at anytime without needing to re write all that code more the once. Imagine having documentation everywhere, and code doing all sorts of stuff like this, it would get confusing way to fast.
Functions are used to encapsulate and organize code, simplify it, code is read more times then its written, its important for it to be clear and readable, programs easily go over the 2 000 lines of code, once you actually write a real program, you'll understand. Also btw,
Parameters are in the function call, so last line of code.
Arguments are in the function definition, at the top.