Saturday, 14 May 2011

python program to swap two numbers.

hi,

I made a python program to swap two numbers.its damn simple in python.

the code is..

#!usr/bin/env python
a=10
b=20
print "a = ",a,"b = ",b
print "after swapping"
a,b=b,a
print "a = ",a,"b = ",b

o/p:

[parthi@parthicomp pyth files]$ python swap.py
a =  10 b =  20
after swapping
a =  20 b =  10

No comments:

Post a Comment