# Exercice 2.2

mon_tuple = (5, 8, 6, 9)
a = mon_tuple[1]

# Exercice 2.3

a, b = (8, 5)

# Exercice 2.4

mon_tab = [5, 8, 6, 9]
mon_tab[0] = 15

# Exercice 2.12

def recherche_max(tab):
    maxi = tab[0]
    for t in tab :
        if t > maxi :
            maxi = t
    return maxi
    
print(recherche_max([4, 3, 0, 5]))

# Exercice 2.13

def somme(tab):
    s = 0
    for t in tab :
        s = s + t
    return s

print(somme([3,5,8,4]))

# Exercice 2.14

def recherche(tab, n):
    indice = -1
    i = 0
    for t in tab :
        if n == t :
            indice = i
        i = i + 1
    return indice

print(recherche([3,5,8,34], 8))
print(recherche([3,5,8,34], 42))

# Exercice 2.15
# Plusieurs façon de le recoder, j'ai réutilisé la fonction somme codée plus haut

def moyenne(tab):
    return somme(tab)/len(tab)
    
print(moyenne([1,2,3,4,5,12]))