Discuss / Python / 交作业

交作业

Topic source

o0stanley0o

#1 Created at ... [Delete] [Delete and Lock User]
def findMinAndMax(L):    if len(L) == 0:        return (None, None)    num_min = L[0]    num_max = L[0]    for num in L:        if num < num_min:            num_min = num        elif num > num_max:            num_max = num    return (num_min, num_max)

o0stanley0o

#2 Created at ... [Delete] [Delete and Lock User]
def findMinAndMax(L):    if len(L) == 0:        return (None, None)    num_min = L[0]    num_max = L[0]    for num in L:        if num < num_min:            num_min = num        elif num > num_max:            num_max = num    return (num_min, num_max)

o0stanley0o

#3 Created at ... [Delete] [Delete and Lock User]

def findMinAndMax(L):

    if len(L) == 0:

        return (None, None)

    num_min = L[0]

    num_max = L[0]

    for num in L:

        if num < num_min:

            num_min = num

        elif num > num_max:

            num_max = num

    return (num_min, num_max)


  • 1

Reply