Aller au contenu

Correction de l'épreuve 42

Sujet (PDF intégré)

Exercice 1

def nb_repetitions(elt, tab):
    nb = 0
    for element in tab:
        if element == elt:
            nb += 1
    return nb

Exercice 2

def binaire(a):
    '''convertit un nombre entier a en sa representation 
    binaire sous forme de chaine de caractères.'''
    if a == 0:
        return '0' 
    bin_a = '' 
    while a != 0 : 
        bin_a = str(a % 2) + bin_a 
        a = a // 2
    return bin_a

Commentaires éventuels

Pourquoi je m'inflige ça ? Pourquoi ne pas aller élever des chèvres en Pentagonie ?

Précédent | Suivant