This commit is contained in:
pvalarcher 2022-11-18 09:17:43 +01:00
parent 3c52421dba
commit b92cb19bfc
6 changed files with 112 additions and 2 deletions

1
python/5/cle.txt Normal file
View File

@ -0,0 +1 @@
wo4Fo\F( u

54
python/5/codage.py Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env python3
import random
file_message = open("message.txt", "r")
file_cle = open("cle.txt", "w")
file_code = open("code.txt", "w")
## Supposons que message.txt contienne
## Il
## fait
## beau!
lignes = file_message.readlines()
for message in lignes:
longM = len(message)
cle = ""
for i in range(longM):
j = random.randint(0,127)
l = chr(j)
cle = cle + l
file_cle.write(cle)
messagecode = ""
for i in range (longM):
ccode = chr( (ord(message[i]) + ord(cle[i])) % 127)
messagecode = messagecode + ccode
file_code.write(messagecode)
file_message.close()
file_cle.close()
file_code.close()

1
python/5/code.txt Normal file
View File

@ -0,0 +1 @@
Jdy(Yf)jk8

36
python/5/esr.py Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
# Polarité;Action;Fait;Valeur;Ordre
f = open("fr-esr-referentiel_de_transformation_numerique_esr.csv","r")
lignes = f.readlines()
chiffres = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
### Recherche de l'indice de la colonne 'Ordre'
entete = lignes[0].split(';')
print (entete)
# entete = ['Polarité', 'Action', 'Fait', 'Valeur', 'Ordre']
indice = 0
while (entete[indice] != 'Ordre') and (entete[indice] != 'Ordre\n'):
indice = indice + 1
print("indice : ", indice)
ordre_min_actuel = 1000000
num_ligne = 0
i = 0
for ligne in lignes:
l = ligne.split(';')
# l[indice][0] c'est le premier caractère
# l[indice] == '89'== ['8', '9']
if l[indice][0] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
if int(l[indice]) < ordre_min_actuel:
ordre_min_actuel = int(l[indice])
num_ligne = i
i = i + 1
print(lignes[num_ligne])

17
python/5/exoNote.py Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python3
nomFic = input("Entrer un nom de fichier : ")
f = open(nomFic, "r")
lignes = f.readlines()
c = 0
for ligne in lignes:
for i in range(len(ligne)):
if ligne[i] == 'a':
c = c + 1
f.close()
print("il y a ", c, " 'a' dans le ficher!")

View File

@ -1,2 +1,3 @@
La pluie est bleue! Il
Q'en pensez vous? fait
beau!