mystere_correction.py

Created by cahier-2de-snt2020

Created on April 28, 2020

869 Bytes

Correction de l’activité 3 p.47 du cahier SNT Bordas


matrice=[[0,0,0,1,0,0,0,0,0,0,0,1,0,0],
         [0,0,0,1,0,0,0,0,0,0,0,0,0,0],
         [0,0,0,1,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,0,0,0,0,0,0,1,0,0,0,0],
         [0,0,0,0,0,1,0,0,0,0,0,0,0,0],
         [0,0,0,0,1,0,1,1,0,1,0,0,0,0],
         [0,0,0,0,0,1,0,0,0,0,0,0,0,0],
         [0,0,0,0,0,1,0,0,1,0,0,0,0,0],
         [0,0,0,0,0,0,0,1,0,0,0,0,0,0],
         [0,0,0,1,0,1,0,0,0,0,0,0,1,0],
         [0,0,0,0,0,0,0,0,0,0,0,0,1,0],
         [1,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [0,0,0,0,0,0,0,0,0,1,1,0,0,1],
         [0,0,0,0,0,0,0,0,0,0,0,0,1,0]]

def mystere(matrice):
    compteur = 0
    nombre_lignes = len(matrice)
    nombre_colonnes = len(matrice[0])
    for i in range(nombre_lignes):
        for j in range(nombre_colonnes):
            if matrice[i][j] == 1:
                compteur = compteur + 1
    return compteur/2