diff --git a/TD02/code/test_file.py b/TD02/code/test_file.py new file mode 100644 index 0000000000000000000000000000000000000000..644a4ca8a9adc947854e6c9b9114a9bf7f084a40 --- /dev/null +++ b/TD02/code/test_file.py @@ -0,0 +1,23 @@ +from File import * + +if __name__=="__main__": + + data = [] + + with open("etudiants.txt") as f: + keys = None + for line in f: + l = [w.strip() for w in line.split(';')] + if keys is None: + keys = l + else: + data.append({k:v for k, v in zip(keys, l)}) + + file = File() + + for d in data: + file.ajoute(d) + + e = file.renvoie(lambda x : x['filiere'] == "PC") + + print(e['nom'] + " " + e['prenom']) \ No newline at end of file diff --git a/TD02/code/test_pile.py b/TD02/code/test_pile.py new file mode 100644 index 0000000000000000000000000000000000000000..8f24e33c0ea84af9438afef3071ed9d1ed918d0c --- /dev/null +++ b/TD02/code/test_pile.py @@ -0,0 +1,21 @@ +from Pile import * + +if __name__=="__main__": + + data = [] + + with open("etudiants.txt") as f: + keys = None + for line in f: + l = [w.strip() for w in line.split(';')] + if keys is None: + keys = l + else: + data.append({k:v for k, v in zip(keys, l)}) + + p = Pile() + for d in data: + p.ajoute(d) + + e = p.supprime() + assert(e['nom'] == "Arthaud" and e['prenom'] == "Nathalie") \ No newline at end of file diff --git a/TD02/code/test_tas.py b/TD02/code/test_tas.py new file mode 100644 index 0000000000000000000000000000000000000000..faa129019cc114cc35b9786cfe1d6f8ae345b296 --- /dev/null +++ b/TD02/code/test_tas.py @@ -0,0 +1,26 @@ +from Tas import * + +if __name__=="__main__": + + data = [] + + with open("etudiants.txt") as f: + keys = None + for line in f: + l = [w.strip() for w in line.split(';')] + if keys is None: + keys = l + else: + data.append({k:v for k, v in zip(keys, l)}) + + tas = Tas() + + for d in data: + tas.ajoute(int(d['moyenne'])) + + r = tas.get_racine() + fg, fg_i = tas.get_fils_gauche(0) + ffg, ffg_i = tas.get_fils_droit(0) + + assert(r == 19 and fg == 14 and ffg == 16) + \ No newline at end of file diff --git a/TD02/td2.pdf b/TD02/td2.pdf index 8cc57195e2b20720ade9f1b806431f43b0fe9608..021fbe1374033556584eb34f59dbb4b0d311d174 100644 Binary files a/TD02/td2.pdf and b/TD02/td2.pdf differ