Python Tutorial

Wednesday, August 18, 2010

python function,method,module

'''
    This code use function syntax
'''

def getMaxValue(data):
    '''
       this method use for get maximum data of a integer array
    '''
    return max(data)

def getMinValue(data):
    '''
       this method use for get minimum data of a integer array
    '''
    return min(data)

def sortData(data):
    '''
       this method use for sort data of a integer array
    '''
    data.sort()
    return data

myArray=[]
myArray.append(1)
myArray.append(2)
myArray.append(6)
myArray.append(3)
'''
   call function
'''
print getMaxValue(myArray)
print getMinValue(myArray)
print myArray
print sortData(myArray)



Output:
6
1
[1, 2, 6, 3]
[1, 2, 3, 6]

0 comments:

Post a Comment