Python 函数


Python 函数

def getMax( set ):
   max = set[0]
   i = 1   
   while( i < 5 ):
      if( max <  set[i] ):
         max = set[i]
      i = i + 1
   return max


set1 = [10, 20, 30, 40, 50]
set2 = [101, 201, 301, 401, 501]

# Process first set of numbers available in set1[]
max = getMax(set1)
print "Max in first set = ", max

# Now process second set of numbers available in set2[]
max = getMax(set2)
print "Max in second set = ", max