Python Program to Swap Two Numbers

Python Program to Swap Two Numbers

In this example, you will get the 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

 

 

 

 

Leave a Comment

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

Scroll to Top