tep-by-Step Explanation:
-
Variable Initialization:
-
You define a variable a with the value 10.
-
-
Function Call:
-
The function modify is called with a as the argument.
-
Inside the function, x = a, so x = 10.
-
-
Inside the Function:
-
This creates a new local variable x inside the function.
-
It adds 5 to x, making x = 15, but this does NOT affect the original a outside the function.
-
-
Printing a:
a still holds the original value 10, because integers are immutable in Python and reassignment inside the function doesn’t change the original variable.
✅ Output:
Key Concept:
Python uses pass-by-object-reference, and integers are immutable. So when you modify a number inside a function, it does not affect the original variable.


0 Comments:
Post a Comment