F How to Swapping of two variables using Python? | CodeTheta

How to Swapping of two variables using Python?

June 13, 2018

Code:
FirstNumber = int(input("Enter first number: "))
SecondNumber = int(input("Enter second number: "))
Temp = FirstNumber
FirstNumber = SecondNumber
SecondNumber = Temp
print ("After swapping first number is: {}".format(FirstNumber))
print ("After swapping second number is: {}".format(SecondNumber))

Output:
Enter first number: 56
Enter second number: 87
After swapping first number is: 87
After swapping second number is: 56

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment