Site de Jean-Michel RICHER

Maître de Conférences en Informatique à l'Université d'Angers

Ce site est en cours de reconstruction certains liens peuvent ne pas fonctionner ou certaines images peuvent ne pas s'afficher.


Code

Fichier : ens/l1/python1/cc/creer_lab.py




Warning: Undefined variable $highlight in /home/jeanmichel.richer/public_html/rendu_code.php on line 43
import math

def main():
    description = "1100101011100111"
    l = len(description)
    n = int(math.sqrt(l))
    lab = []
    index = 0
    for y in range(n):
        row = []
        for c in range(n):
            row.append(int(description[index]))
            index += 1
        lab.append(row)

    print(lab)
    for row in lab:
        print(' '.join(str(x) for x in row))
       

if __name__ == "__main__":
    main()