+ 1

Python function

i didn't understand the functions with arguments,what it's for(argumets)?

19th Sep 2017, 6:22 PM
Federico Nardo
Federico Nardo - avatar
2 Antworten
+ 5
In any P/L, not Python in particular, a function argument is used for transporting data between the function caller and the function itself. Basically, most coder distinct arguments by their purpose, where it is commonly said "pass by value" or pass by reference". Passing argument by value means to create a copy of the passed argument's content inside the function for the function to work with. The original argument's content, in the function caller side, whatever it is, remains unchanged, changes that applied inside the function does not reflect on the original argument content in the function caller side. Passing argument by reference means to pass the original argument directly into the function, this means, every changes applied to the argument also reflected in the function caller side. Imagine a scenario like this; you (function caller), and your friend (the function), the argument is a book, so you call your friend, Pass by value: You give him/her book, but s/he may not write anything in the book, s/he must make a copy of it, and write on that copy, your book is unchanged. Pass by reference: You give him/her book, and, s/he can do whatever on the book, write, draw etc. so when you get your book back, it is possible that the book has been changed. Well, there you go, I hope I made it clear enough, and that it's not too long to read. Hth, cmiiw
19th Sep 2017, 9:16 PM
Ipang
0
Did you ever do in and out boxes in math on first grade? The argument is what you are putting in. Then it returns what comes out.
19th Sep 2017, 10:10 PM
Arthur Tripp
Arthur Tripp - avatar