Begin22. Swap the contents of the variables \(A\) and \(B\) and output new values of \(A\) and \(B\).
Solution in Python 3:
import random
A,B = sorted(random.sample(range(-10, 10), 2))
print("A = {0}, B = {1}".format(A,B))
A,B = B,A
print("A = {0}, B = {1}".format(A,B))
A = B + A
B = A - B
A = A - B
print("A = {0}, B = {1}".format(A,B))
X = B
B = A
A = X
print("A = {0}, B = {1}".format(A,B))