python found to achieve the maximum and minimum number of series

Writing functions minmax (data), is used to find the maximum and minimum number of sequences, the length and in the form of a 2-tuple of the built-in functions can not return note max, min

def minmax(datas):
    num=[]
    max=datas[0]
    min=datas[0]
    for data in datas:
        if max<data:
            max=data
        if min>data:
            min=data
    num.append(min)
    num.append(max)
    return num
datas=[]
print("输入10个整数")
for i in range(0,10):
    j=(int)(input())
    datas.append(j)
num=minmax(datas)
print("最小值:"+ str(num[0]))
print("最大值:"+ str(num[1]))

Guess you like

Origin blog.csdn.net/qq_44822951/article/details/92073906