Search Program on this blog

Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Sunday, 23 August 2015

Insertion Sort in Python

def sort(c):
        for i in range(0,len(c),1):
                j=i
                while(j>0):
                        if(c[j]<c[j-1]):
                                c[j],c[j-1]=c[j-1],c[j]
                        j-=j 
        return c
                
a=[10,23,54,23,32,98,87]
print a
b=sort(a)
print b

Tuesday, 18 August 2015

Python: Beginning with python

print 'Hello world'

#save file using .py formate and execute e.g. test.py
#output:Hello world