Sie sind auf Seite 1von 1

###################### 10.4.

3 Variable number of arguments def maximum(*numbers): if len(numbers) == 0: return(None) else: max = numbers[0] for n in numbers[1:]: if n > max: max = n return max def exampleFun(x, y, **other): print "x:", x, "y:", y, ",keys in 'other':",other.keys() otherTotal = 0 for k in other.keys(): otherTotal = otherTotal + other[k] print "The total of values in 'other' is", otherTotal ###################### 10.5 Mutable objects as arguments def f(n, list1, list2): list1.append(3) list2 = [4, 5, 6] n = n+1 ###################### 10.6 Local and global variables def fact(n): """Return r = 1 while n > r = r n = n return r the factorial of the given number.""" 0: * n - 1

Das könnte Ihnen auch gefallen