Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
1 result

Target

Select target project
  • rvuillem/inf-tc1
  • hwei/inf-tc1
  • nmbengue/inf-tc1
  • fernanda/inf-tc1
  • mleger/inf-tc1
  • lmeng/inf-tc1
  • gferryla/inf-tc1
  • jconso/inf-tc1
  • smaghsou/inf-tc1
  • emarquet/inf-tc1
  • ecluzel/inf-tc1
  • aaudeoud/inf-tc1
  • tsegond/inf-tc1
  • aetienne/inf-tc1
  • djoly/inf-tc1
  • bcampeas/inf-tc1
  • dnovarez/inf-tc1
  • ruetm/inf-tc1
  • cchenu/inf-tc1
  • cguiotdu/inf-tc1
  • mclouard/inf-tc1
  • gwachowi/inf-tc1
  • qbaalaou/inf-tc1
  • sbrocas/inf-tc1
  • ppupion/inf-tc1
  • kinty/inf-tc1
  • hadomo/inf-tc1
  • tgicquel/inf-tc1
  • rhahn/inf-tc1
  • cguyau/inf-tc1
  • mpairaul/inf-tc1
  • rmuller/inf-tc1
  • rlecharp/inf-tc1
  • asebasty/inf-tc1
  • qmaler/inf-tc1
  • aoussaid/inf-tc1
  • kcherigu/inf-tc1
  • sgu/inf-tc1
  • malcalat/inf-tc1
  • afalourd/inf-tc1
  • phugues/inf-tc1
  • lsteunou/inf-tc1
  • llauschk/inf-tc1
  • langloia/inf-tc1
  • aboucard/inf-tc1
  • wmellali/inf-tc1
  • ifaraidi/inf-tc1
  • lir/inf-tc1
  • ynedjar/inf-tc1
  • schneidl/inf-tc1
  • zprandi/inf-tc1
  • acoradid/inf-tc1
  • amarcq/inf-tc1
  • dcombet/inf-tc1
  • mrosini/inf-tc1
  • gplaud/inf-tc1
  • mkernoaj/inf-tc1
  • bboyer/inf-tc1
  • gbichot/inf-tc1
  • tdutille/inf-tc1
60 results
Select Git revision
  • master
1 result
Show changes
Showing
with 2365 additions and 204 deletions
# 7 Types principaux en Python
if type(1) is not int : print('oups')
if type('1') is not int : print(1)
type(3.14)
# float
type(None)
# NoneType
f = lambda c : c if type(c) is str and c.isalpha() else '?'
type(f)
# function
# Utilisation de f (voir plus loin les "lambda expressions") :
f('a') # donne 'a' car 'a' est alphabétique
f('1') # donne '?' car '1' n'est pas alphabétique
f(1) # donne '?' car 1 n'est pas une chaine
import sys;
print(sys.int_info)
# sys.int_info(bits_per_digit=30, sizeof_digit=4)
print(sys.float_info)
# sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308,
# min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15,
# mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
print(sys.getsizeof(float)) # La taille de la classe float
# 400
print(sys.getsizeof(float())) # La taille d'un float
# 24 # Ce que coute en octes un réel
# (valeur + infos supplémentaires)
# Vous devez valider ce code qui affiche le numéro de version
# Rien d'autre à faire !
import sys
if not sys.version_info.major == 3 and sys.version_info.minor >= 7:
print("Python 3.7 ou supérieur est nécessaire !")
else:
print("Vous utilisez {}.{}.".format(sys.version_info.major, sys.version_info.minor))
sys.exit(1)
\ No newline at end of file
code = zip([1000,900 ,500,400 ,100,90 ,50 ,40 ,10 ,9 ,5 ,4 ,1], ["M" ,"CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"])
# fonctions
def zipConversionRomain(num):
res = []
for d, r in code:
while num >= d:
res.append(r)
num -= d
return ''.join(res)
# programme principal -----------------------------------------------
for i in range(1, 15):
print(i, zipConversionRomain(i))
\ No newline at end of file
File deleted
This diff is collapsed.
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
#%%
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")
# %%
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
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
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
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
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
nom;prenom;filiere;moyenne;absences
Dickerson;Chaney;PSI;6;4
King;Shay;PSI;2;2
Chan;Aileen;MP;8;3
Schwartz;Destiny;PSI;16;5
Parrish;Prescott;MP;1;4
Calhoun;Brenda;PSI;10;4
Watts;Shellie;PSI;6;4
Baird;Octavius;PC;4;2
Graves;Vanna;MP;10;0
Decker;Nerea;PSI;9;4
Townsend;Naomi;PC;13;3
Decker;Nichole;PSI;10;3
Mcgee;Blythe;PSI;7;0
Franco;Cyrus;PSI;12;1
Mcdowell;Zelda;MP;6;1
Cherry;Stone;PSI;10;5
Mendoza;Kirsten;PC;18;0
Mathis;Xaviera;MP;12;1
Booker;Gretchen;MP;2;1
Hansen;Slade;PSI;1;1
Mason;Forrest;MP;13;3
Wolfe;Fatima;PC;15;5
Richards;Justine;MP;20;0
Kelley;Abra;PC;2;4
Lang;Ulysses;PSI;2;5
Barker;Austin;MP;15;5
Cannon;Kalia;MP;3;4
Higgins;Charity;PSI;18;5
Parker;Fritz;PC;14;2
Chambers;Yvette;PSI;7;1
Vinson;Denise;PSI;3;5
Mcmillan;Chava;PSI;7;3
Gallegos;Lee;PC;16;0
Ferguson;Solomon;PSI;11;4
Camacho;Zena;MP;4;4
Sexton;Fallon;PSI;16;2
Campbell;Preston;PC;0;0
Greer;Lance;PC;15;5
Oliver;Aileen;PC;10;2
Nielsen;Timon;PC;1;2
Perkins;Roth;PSI;1;2
Beard;Blair;PSI;13;1
Burgess;Keely;PSI;4;4
Wells;Honorato;PSI;17;0
Richardson;Cherokee;PC;20;1
Burgess;Blair;PC;16;4
Rice;Florence;PC;7;4
Villarreal;Delilah;MP;9;5
Cherry;Maite;MP;0;2
Berry;Jermaine;MP;17;4
Shepherd;Alfreda;PSI;20;5
Workman;April;PC;3;1
Carter;Herman;PC;11;1
Carpenter;Teagan;MP;0;1
Fowler;Leo;PSI;19;4
Mcgee;Kristen;PSI;9;4
Mcpherson;Channing;PC;0;0
Diaz;Nathaniel;PC;4;5
Klein;Maisie;PSI;16;3
Graham;Gary;MP;12;4
Jensen;Raja;PC;18;1
Wilkinson;Sawyer;PSI;10;0
Wagner;Lamar;MP;16;2
Abbott;Sybil;MP;17;1
Glenn;Arsenio;PSI;4;3
Moreno;Axel;PSI;7;4
Barrett;Dylan;PC;14;4
Keith;Rae;PC;9;1
Shepard;Rebecca;PC;8;5
Meyers;Illiana;MP;3;3
Bruce;Tatyana;MP;2;0
Mcguire;Olivia;PC;17;4
Merritt;Tatiana;PSI;19;3
Berg;Dale;MP;12;1
Matthews;Tallulah;MP;5;3
Steele;Cain;MP;8;2
Ellison;Britanni;PC;4;1
Richards;Audra;MP;15;0
Hood;Rylee;PSI;1;4
Townsend;Paul;PC;14;4
Cervantes;Thaddeus;MP;10;5
Dudley;Amela;PC;2;0
Lucas;Matthew;MP;4;1
Parrish;Nell;PC;13;3
Patterson;Bertha;PSI;18;0
Knapp;Lawrence;MP;3;5
Stanton;Keith;MP;5;2
Hayes;Mannix;PSI;3;2
Pearson;Ross;PC;10;4
Kaufman;Uta;MP;10;4
Bauer;Naida;PC;20;5
Carrillo;Quamar;PC;15;3
Orr;Lisandra;PSI;6;2
Randolph;Darryl;PSI;16;4
Boyer;Prescott;PC;20;2
Serrano;Ashely;PSI;10;2
Carney;Oren;PC;7;4
Riley;Arden;PC;1;5
Phillips;Joshua;PSI;20;3
Soto;Colt;PC;16;3
\ No newline at end of file
nom;prenom;filiere;moyenne;absences nom;prenom;filiere;note;absences
Dupond;Pierre;MP;19;0 Dupond;Pierre;MP;19;7
Dupont;Jeanne;MP;19;5
Clavier;Christian;PSI;14;1 Clavier;Christian;PSI;14;1
Gilles;Eric;PC;16;3 Gilles;Eric;PC;16;3
Arthaud;Nathalie;MP;15;0 Arthaud;Nathalie;MP;15;0
\ No newline at end of file
File deleted
This diff is collapsed.
TD03/Image10.bmp

192 KiB

TD03/Image8.bmp

2.84 MiB

from graphviz import Digraph
name = 'arbre-viz-profondeur'
g = Digraph('G', filename = name + '.gv', format='png') # par defaut format='pdf'
g.edge('chien', 'petit')
g.edge('chien', 'et')
g.edge('petit', 'le')
g.edge('et', 'jaune')
g.edge('et', 'noir')
# génere et affiche le graphe name.gv.png
g.view()
\ No newline at end of file
TD03/ecl.jpg

103 KiB