How to swap two numbers using python code

In this tutorial, we are going to show How to Swap two numbers using python without using a third variable. We have added the video tutorial and the source code of the program.

Video Tutorial: Swap two numbers using python code

Source Code

# Python program to swap two numbers

a = input('Enter value of a: ')
b = input('Enter value of b: ')

print('\nOriginal Values \n a=',a,'\n b=',b)

a,b = b,a 

print('\nAfter Swapping\n a=',a,'\n b=',b)

Output

Also Read: Python program to create bmi calculator

Leave a Reply

Your email address will not be published.