Python Program to Swap Two Numbers

Python program to Swap Two Numbers

Here you will learn an example code of python program to swap two numbers with and without using third variable in python programming.

 

Python program to swap two numbers using third variable

Output

Enter value of x: 4
Enter value of y: 5
The value of x after swapping: 5
The value of y after swapping: 4

 


 

Python program to swap two numbers without third variable

Output

Enter value of x: 10
Enter value of y: 20
The value of x after swapping: 20
The value of y after swapping: 10

 

 

 

Check out our other Python examples

 

 

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top