A Program to Swap Two Variables
In this example, we are giving a program to swap two variables.
Program to swap two variables:
# Swap two variable
a = float(input('Enter the value of a: '))
b = float(input('Enter the value of b: '))
temp = a
a = b
b = temp
print('The value of a after swapping: {}'.format(a))
print('The value of b after swapping: {}'.format(b))
Output:
Enter the value of a: 5 Enter the value of b: 7 The value of a after swapping: 7.0 The value of b after swapping: 5.0