Python program to swap the given numbers
kw.py
print("__________________________________________")
print("Program to swap the two numbers")
print("__________________________________________")
a=int(input("a = "))
b=int(input("b = "))
a=a+b
b=a-b
a=a-b
print("__________________________________________") 
print("After swapping...")
print("__________________________________________")
print("a = ",a)
print("b = ",b)
print("__________________________________________")
Output
kodingwindow@kw:~$ python3 kw.py
__________________________________________
Program to swap the two numbers
__________________________________________
a = 1024
b = 2048
__________________________________________
After swapping...
__________________________________________
a = 2048
b = 1024
__________________________________________
Advertisement