diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9bea4330f055c418ce73df7a354fd5c29ead0631 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/TD02/code/etudiants.txt b/TD02/code/etudiants.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe575b476f827b2320c3bd1fda744385abb25d0b --- /dev/null +++ b/TD02/code/etudiants.txt @@ -0,0 +1,5 @@ +nom;prenom;filiere;moyenne;absences +Dupond;Pierre;MP;19;0 +Clavier;Christian;PSI;14;1 +Gilles;Eric;PC;16;3 +Arthaud;Nathalie;MP;15;0 \ No newline at end of file diff --git a/TD02/code/load.py b/TD02/code/load.py new file mode 100644 index 0000000000000000000000000000000000000000..4be2b6c5b3fdf4de192859e76ad6126956225576 --- /dev/null +++ b/TD02/code/load.py @@ -0,0 +1,12 @@ +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(l) + +print(data) \ No newline at end of file diff --git a/TD02/code/test_analyse.py b/TD02/code/test_analyse.py new file mode 100644 index 0000000000000000000000000000000000000000..cfab6e73c1985aaafe0b20a278dcf358e083e7b2 --- /dev/null +++ b/TD02/code/test_analyse.py @@ -0,0 +1,28 @@ +#%% +import time +import random +import matplotlib.pyplot as plt +import numpy as np +#%matplotlib inline + +nvalues = [100, 500, 1000, 1500, 2000, 2500, 3000] +timesEtudiants1 = [] + +for i in nvalues: + + random.seed() + p = 12**2 # Ordre de grandeur des valeurs + liste = [] + + for x in range(i): liste.append(random.randint(0, p)) + + a=time.perf_counter() + e1 = [] + for n in liste: + e1.append(n) + b=time.perf_counter() + timesEtudiants1.append(b-a) + +plt.plot(nvalues,timesEtudiants1, "r-", label="Etudiants 1") +plt.title("Comparaison des performances") +# %% diff --git a/TD02/code/test_heap.py b/TD02/code/test_heap.py new file mode 100644 index 0000000000000000000000000000000000000000..5514c098c8452628f127ff6ff3f9582da3dd258b --- /dev/null +++ b/TD02/code/test_heap.py @@ -0,0 +1,9 @@ +import heapq +tas = [] + +for i in range(5): heapq.heappush(tas, i) + +while not len(tas) == 0: + print(heapq.heappop(tas), end=" ") + +# 0 1 2 3 4 \ No newline at end of file diff --git a/TD02/code/test_lifoqueue.py b/TD02/code/test_lifoqueue.py new file mode 100644 index 0000000000000000000000000000000000000000..09a4716f4c404fab7429b09349745dd1347e7557 --- /dev/null +++ b/TD02/code/test_lifoqueue.py @@ -0,0 +1,9 @@ +import queue +pile = queue.LifoQueue() + +for i in range(5): pile.put(i) + +while not pile.empty(): + print(pile.get(), end=" ") + +# 4 3 2 1 0 \ No newline at end of file diff --git a/TD02/td2.pdf b/TD02/td2.pdf new file mode 100644 index 0000000000000000000000000000000000000000..954d95eed9065c656f40886ac5f03e21faa737f4 Binary files /dev/null and b/TD02/td2.pdf differ