def fn(a,b,*args):
maxnum = max(a,b,*args)
minnum = min(a,b,*args)
return maxnum,minnum
运行结果:
#fn(1,2,3,4)
(4, 1)
案例变形:
import random
def fn(*nums):
print(nums)
return max(nums),min(nums)
print(*fn(*[random.randint(10,20) for _ in range(10)]))
运行结果:
(18, 16, 19, 20, 10, 13, 14, 12, 14, 20)
20 10