Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

Python - Swap 3 numbers

Viewed:  3668 
Posted On:  23/05/2015 22:50:56 
In this article I am going to explain how we can swap the values of 3 variables.... 


Here I am going to explain how we can swap 3 numbers in Python.

Step 1: Open IDLE(Python GUI) in your system.

Step 2 : Type the Below code and save the code Eg:- I have saved with swap name.

a = 8
b = 7
c = 12

print("the value before swaping is",a,b,c)

d = a+b+c
b = a
a = c
c = d-(a+b)

print("the value after swaping is",a,b,c)
Step 3 :
 Open command prompt.

Step 4 : Go to the saved script folder.

Step 5 : Write python <Script name>.py  for execution.(Eg.- python



Image 1.

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us