How are arguments passed by value or by reference in Python?

Hi, How are arguments passed by value or by reference in python

1 Like

Python only accepts Pass by reference type of arguments, which means that all the parameters passed will change, if the value at reference source changes.

Syntax:

def function_name(parameter1, parameter2, ...):
    .
    .

Example:

def add(a, b):
    print("Sum = ", a+b)
    return

add(2, 3)
add(4, 5)

Output:

Sum = 5

Sum = 9

1 Like