Illustrate parameter passing: tuple, type and tuple : Function Tuple Parameters « Function « Python






Illustrate parameter passing: tuple, type and tuple

Illustrate parameter passing: tuple, type and tuple
       
def min1(*args):
    res = args[0]
    for arg in args[1:]:
        if arg < res:
            res = arg
    return res

def min2(first, *rest):
    for arg in rest:
        if arg < first:
            first = arg
    return first

def min3(*args):
    tmp = list(args)
    tmp.sort()
    return tmp[0]

print min1(3,4,1,2)
print min2("bb", "aa")
print min3([2,2], [1,1], [3,3])



           
       








Related examples in the same category

1.Any number of parameter: turn parameter into a tupleAny number of parameter: turn parameter into a tuple
2.Unpacking Argument ListsUnpacking Argument Lists
3.Arbitrary Argument Lists
4.Parameter passing: mixed with dictionary and tupleParameter passing: mixed with dictionary and tuple
5.Re design the intersect and union using tuple parameter passing