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
-
AWS Interview Q&A for Beginners (Must Watch!)

The content outlines essential AWS basics interview questions that every beginner should be familiar with. It serves as a resource for fresh candidates preparing for interviews in cloud computing. The link provided leads to additional multimedia content related to the topic.
-
How a PySpark Job Executes: Understanding Statements, Stages, and Tasks

When you write a few lines of PySpark code, Spark executes a complex distributed workflow behind the scenes. Many data engineers know how to write PySpark, but fewer truly understand how statements become stages, stages become tasks, and tasks run on partitions. This blog demystifies the internal execution model of Spark by connecting these four…
-
Azure Data Factory (ADF): The Complete Beginner-Friendly Guide (2026 Edition)

Azure Data Factory (ADF) is Microsoft’s fully managed, cloud-based data integration and orchestration service. It helps you collect data from different sources, transform it at scale, and load it into your preferred analytics or storage systems. Whether you are working with Azure SQL, on-premises databases, SaaS applications, or big-data systems, ADF gives you a unified…




You must be logged in to post a comment.