Python Program to Swap Two Numbers
def swap(x,y): x,y=y,x print("After swap:") print("First number=",x) print("Second number=",y) x=input("Enter the first number:") y=input("Enter the second number:") print("Before swap:") print("First number=",x) print("Second number=",y) swap(x,y)
Output:
Enter the first number: 20
Enter the second number: 25
Before swap:
First number= 20
Second number= 25
After swap:
First number= 25
Second number= 20