Write a program to accept two numbers from user. Swap the values of
the variables using third variable. Display the values before and after
swapping
Answers
Answered by
1
Language:
Python
Program:
a,b= int(input("Enter 1st number: ")),int(input("Enter 2nd number: "))
print(f"\nBefore swapping: {a},{b} ")
a,b=b,a
print(f"\nAfter swapping: {a},{b} ")
Output:
Enter 1st number: 8
Enter 2nd number: 9
Before swapping: 8,9
After swapping: 9,8
Explanation:
- Accepts value in a and b.
- Print them with a statement.
- Swap.
- Print them with statement.
Similar questions