# Exercice 1
# Question 1
def moyenne(L):
    S = 0
    for x in L:
        S = S+x
    return S/len(L)

# Question 2
def maximum(L):
    if L[0] > L[1]:
        m1,m2 = L[0],L[1]
    else :
        m2,m1 = L[0],L[1]
    for i in range(2,len(L)):
        if L[i] > m1:
            m1,m2 = L[i],m1
        elif L[i] > m2:
            m2 = L[i]
    return m1,m2



# Question 3
def moyenne(L):
    return L[len(L)-1]

# Question 4
def present(L,x):
    rep = False
    for i in L:
        if i == x:
            rep = True
    return rep

# Question 5
def inserer(L,x):
    i = 0
    while i < len(L) and x > L[i]:
        i = i+1
    L.insert(i,x)
    return L


# Question 6
def miroir(L):
    M = []
    for i in range(len(L)):
        M.append(L[len(L)-i-1])
    return M

# Question 7
def condition(L,f):
    Mv,Mf = [],[]
    for x in L:
        if f(x) :
            Mv.append(x)
        else :
            Mf.append(x)
    return Mv,Mf

# Question 8
def image(L,f):
    M = []
    for x in L:
        M.append(f(x))
    return M

# Question 9
def repetition(L):
    M = []
    for i in range(len(L)-1):
        if L[i] in L[i+1:len(L)] and L[i] not in M:
            M.append(L[i])
    return M
