Write a program that prompts the user to enter number in two variables and Swap the contents of the variables.
Source Code
# prompt user to enter two numbers
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
# print the original values
print("Before swapping, first number is", num1,"and second number is", num2)
# swap the values
temp = num1
num1 = num2
num2 = temp
# print the swapped values
print("After swapping, first number is", num1,"and second number is", num2)
Output
Enter the first number: 10
Enter the second number: 15
Before swapping, first number is 10 and second number is 15
After swapping, first number is 15 and second number is 10