filmov
tv
WAP - 5 || Write a program to input two numbers and #SWAP them|| #Python|

Показать описание
Write a program to input two numbers and SWAP them
Program-1
x = 5
y = 10
# create a temporary variable and swap the values
temp = x
x = y
y = temp
print('The value of x after swapping: {}'.format(x))
print('The value of y after swapping: {}'.format(y))
Output
x = 5
y = 10
Program-2
x, y = y, x
print("x =", x)
print("y =", y)
Program-1
x = 5
y = 10
# create a temporary variable and swap the values
temp = x
x = y
y = temp
print('The value of x after swapping: {}'.format(x))
print('The value of y after swapping: {}'.format(y))
Output
x = 5
y = 10
Program-2
x, y = y, x
print("x =", x)
print("y =", y)