Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (22 sloc) 401 Bytes
# Python Program to Swap Two Variables without Using Temporary Variable
"""
Addition and Subtraction
x = x + y
y = x - y
x = x - y
Multiplication and Division
x = x * y
y = x / y
x = x / y
"""
x = 5
y = 7
print("Before Swapping: ")
print("Value of x = ", x)
print("Value of y = ", y)
x = x + y
y = x - y
x = x - y
print("After Swapping: ")
print("Value of x = ", x)
print("Value of y = ", y)
You can’t perform that action at this time.