In programming, the = sign is known as the assignment sign. It means that a value on the right of the = sign is being assigned to a variable on the left.
For example, we have the statement x = y. This is defined in programming terminology as x ← y.
In the editor, we will type, as an example:
x = 5
y = 10
x = y
print ("x =", x)
print ("y =", y)
Once run, it will give the output:
x = 10
y = 10
The variable x may have an initial value of 5, but since x = y (x ← y), the value of x changes to 10 with y remaining unchanged.
If we change the third line of the code to y = x, x will be assigned to y and the output will be as follows:
x = 5
y = 5
Mathematically, x = y and y = x mean the same thing, but it is completely different in programming as with the examples shown above.
No comments:
Post a Comment