Pass means to provide arguments for the functions, and the arguments contain information.
When you pass arguments like whole numbers (int, float, etc.), strings, or tuple data type to a function, the passing of the function is like call-by-value because the user cannot modify the value of the non-changeable objects(immutable) being passed to the function. If we try to modify the function, this will not affect the passed value inside the argument. We can use pass by Assignment only when we want the argument to be fixed and not change during the entire program. The values of the variable, once stored into their dummies, can not be changed.
Whereas passing changeable or mutable objects (list) to the function can be considered call-by-reference because when their values are changed inside the function passed, it will also be changed outside the function.
Assignment pass can not provide any changes to the defined arguments, but if the values can be defined through any reference, we can change the value with the help of reference. If we can perform any operation on the function, it will directly affect the variable to which it refers as the argument is referenced.
Suppose we can perform any function operation on the variable. In that case, its initial address will not change, but if we use operators or reassign the variable, then the initial address will change.
Python uses a specific system, which is known as “Call by Object Reference” or “Call by assignment”.
1knowledge2life website
2knowledge2life website
3knowledge2life website
|