3 Commits

Author SHA1 Message Date
Valentin Loison 9e475f7fb4 ajout du dossier img 2026-10-14 12:36:25 +02:00
Valentin Loison 540e80e009 img 2026-10-14 12:35:21 +02:00
Valentin Loison ac6946e442 resolution du tp 2026-10-14 12:34:08 +02:00
9 changed files with 74 additions and 16 deletions
+31
View File
@@ -0,0 +1,31 @@
Valentin Loison
Dimitri Solar
Jannie Ngoy Ituka
Tarehi Zaabay
# Qualité Algo : TD2
| Fonction | Noeuds (N) | Arêtes (E) | Complexité M = E - N + 2P = … avec P = 1 | M = décisions + 1 = … | Classement du code : | Cas particulier ? |
| --- | --- | --- | --- | --- | --- | --- |
| C1 | | | | 1 | Simple | Non |
| C2 | 5 | 5 | 3 | 3 | Simple | Non |
| C3 | | | | 4 | Simple | && et |
| C4 | 10 | 16 | 8 | 8 | Simple | Non |
| C5 | | | | 9 | Simple | Non |
| C6 | | | | 11 | Modéré | Non |
| J1 | | | | 1 | Simple | Non |
| J2 | 6 | 8 | 4 | 4 | Simple | &&` |
| J3 | | | | 8 | Simple | Non |
| J4 | | | | 8 | Simple | Non |
| J5 | | | | 11 | Modéré | Non |
| J6 | 23 | 29 | 8 | 8 | Simple | Non |
| P1 | | | | 1 | Simple | Non |
| P2 | | | | 3 | Simple | Non |
| P3 | 6 | 8 | 4 | 4 | Simple | encadrement 0<=n<=20 on peut considérer ça comme 2 ifs, donc 2 décisions |
| P4 | | | | 2 | Simple | |
| P5 | | | | 15 | Modéré | |
# Images
Pour accéder aux images aller dans le dossier 'img' .
voir exercices.py pour le code refactorisé.
+43 -16
View File
@@ -33,39 +33,66 @@ def mention(moyenne):
return libelle
return "Ajourné"
def analyser_caractere(c,majuscule,minuscule,chiffre,special):
# Exercice P5
def analyser_mot_de_passe(mdp, login=None):
problemes = []
if len(mdp) < 12:
if c.isupper():
majuscule = True
elif c.islower():
minuscule = True
elif c.isdigit():
chiffre = True
else:
special = True
return majuscule,minuscule,chiffre,special
def verif_petit(len, problemes):
if len <12:
problemes.append("trop court")
majuscule = minuscule = chiffre = special = False
for c in mdp:
if c.isupper():
majuscule = True
elif c.islower():
minuscule = True
elif c.isdigit():
chiffre = True
else:
special = True
if not (majuscule and minuscule):
def verif_no_min_maj(min,maj,problemes):
if not (maj and min):
problemes.append("mélanger majuscules et minuscules")
def verif_chiffre(chiffre,problemes):
if not chiffre:
problemes.append("ajouter un chiffre")
def verif_special(special,problemes):
if not special:
problemes.append("ajouter un caractère spécial")
def verif_mdp_is_not_login(login,mdp,problemes):
if login and login.lower() in mdp.lower():
problemes.append("ne pas contenir le login")
def verif_carac_identique(mdp,problemes):
for i in range(len(mdp) - 2):
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
problemes.append("éviter 3 caractères identiques")
break
return
def verif_fort(problemes):
if not problemes:
return "fort", []
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
def analyser_mot_de_passe(mdp, login=None):
problemes = []
majuscule = minuscule = chiffre = special = False
for c in mdp:
majuscule,minuscule,chiffre,special = analyser_caractere(c,majuscule,minuscule,chiffre,special)
print(majuscule,minuscule,chiffre,special)
verif_petit(len(mdp), problemes)
verif_no_min_maj(minuscule,majuscule,problemes)
verif_chiffre(chiffre,problemes)
verif_special(special,problemes)
verif_mdp_is_not_login(login,mdp,problemes)
verif_carac_identique(mdp,problemes)
return verif_fort(problemes)
if __name__ == "__main__":
print(celsius_vers_fahrenheit(20), signe(-3), notes_valides([12, 25, -1, 8]),
mention(13.5), analyser_mot_de_passe("Motdepasse123!", "maxime"))
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB