0% found this document useful (0 votes)
3 views1 page

Assignment (Functions)

The document explains two concepts in programming: pass by value and pass by reference. Pass by value creates a copy of a variable for modification, leaving the original unchanged, while pass by reference allows direct modification of the original variable. Examples are provided to illustrate both concepts in a programming context.

Uploaded by

cgh8s595rr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Assignment (Functions)

The document explains two concepts in programming: pass by value and pass by reference. Pass by value creates a copy of a variable for modification, leaving the original unchanged, while pass by reference allows direct modification of the original variable. Examples are provided to illustrate both concepts in a programming context.

Uploaded by

cgh8s595rr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HILLTON JNR KUFAHAKURAMBWI

PASS BY VALUE

•This is where a function creates a copy of a variable that will be modified however the original
variable will remain same and it will not change.

Example

Main()

Area(L,W)

Area = L *W

Print(“The area is”Area)

Return Area

def House(Area,Price)

House =Area * Price

Print(House)

PASS BY REFERENCE

•Pass by reference is where a function receives a direct reference to the original variable's
memory location, allowing it to modify the variable directly. This means any changes made to
the variable within the function will affect the original variable outside the function.

Example
Area (List A) return
List [2] + 2

Main()
List = [ 5, 6, 7, 8]
Area (List)
Output Area
Output List

You might also like