Passing a value and passing a reference explained below. Below is the simple example which shows how to use these in python.

What is Pass by value
What is pass by value? Passing a value as an argument to the function. The pass-by-value concept explained in three steps.
- Create a function
- pass value as an argument to the function
- to verify the result
A literal (20) as an argument supplied here. So it is called pass-by-value.
def my_pass_by_value(b):
b += 2
print(b)
c=my_pass_by_value(20)
print(c)
The result:
22
None
** Process exited - Return Code: 0 **
Press Enter to exit terminal
What is Pass by reference
Supplying a reference instead of value is called pass-by-refefence. The working principle you can see in the below example.
- Create a function
- pass reference as an argument to the function
- to verify the result
The below example tells how pass-by-reference works. Value not supplied, instead of the value provided a variable (reference).
def my_pass_by_reference(r):
r += 10
print(r)
ref1=100
h=my_pass_by_reference(ref1)
print(h)
The result
110
None
** Process exited - Return Code: 0 **
Press Enter to exit terminal
Recent topics
-
2-Minute Random Topics to Improve English Speaking Skills

Speaking English fluently requires regular practice, confidence, and clear communication. One of the best ways to improve fluency is by speaking for two minutes on random topics. This method helps improve vocabulary, pronunciation, grammar, and thinking in English. In this blog post, you will find popular 2-minute speaking topics along with key points you can…
-
Spark Structured Streaming vs Spark Declarative Pipelines (SDP): What Every Data Engineer Should Know

Compare Spark Structured Streaming vs Spark Declarative Pipelines (SDP) on Databricks. Learn key differences, use cases, code examples, and when to use each.
-
Linking Words Practice: Improve Your English Speaking Fluency Naturally

Learn how to use linking words in English speaking with practical examples. Improve your fluency, communication skills, and confidence using transition words for conversations, presentations, and interviews.







You must be logged in to post a comment.