What will be the output of the following code snippet?
x = 1
y = 2
z = x
x = y
y = z
print (x, y)
A . 1 2
B. 2 1
C. 1 1
D. 2 2
Answer: B
Explanation:
Topic: copying an immutable object by assigning
Try it yourself:
x = 1
y = 2
z = x
print(z) # 1
x = y
print(x) # 2
y = z
print(y) # 1
print(x, y) # 2 1
Integer is an immutable data type.
The values get copied from one variable to another.
In the end x and y changed their values.
Latest PCEP-30-02 Dumps Valid Version with 124 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund