|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
TRADUCTEUR LEET SPEAK
Information sur la source
Description
Bonjour ! Voici ma première source en Python. Je le bosse depuis seulement quelques jours. Ce code rassemble : -récupérer une chaîne de caractère -traiter une chaîne de caractère -utiliser les boucles While -utiliser le traitement par condition : if - elif - else -utiliser les nombres aléatoires -afficher des caractères Ce code permet, de récupérer une chaîne de caractère et de la tranformer en language leetspeak (leet speak --> elite speak --> wikipedia ^.^ ). En leet speak, chaque caractère peut correspondre à plusieurs caractères, pour cela, j'utilises les nobres aléatoires pour les définir. Visionnez le code maintenant ;) Vous pouvez aussi regarder la capture d'écran ! Bonne lecture, ou devrais-je dire : 80^//\/[- |3(7(_)|^&
Source
- #!/usr/bin/python
-
- phrase = raw_input()
- from random import randrange
-
- x = ''
- i = 0
-
- while i < len(phrase):
- if (phrase[i] == 'A') or (phrase[i] == 'a'):
- r = randrange(1,7)
- if r == 1:
- x = x + '4'
- if r == 2:
- x = x + '/\\'
- if r == 3:
- x = x + '@'
- if r == 4:
- x = x + '^'
- if r == 5:
- x = x + 'aye'
- if r == 6:
- x = x + '/-\\'
- if r == 7:
- x = x + '|-\\'
- elif (phrase[i] == 'B') or (phrase[i] == 'b'):
- r = randrange(1,10)
- if r == 1:
- x = x + '8'
- if r == 2:
- x = x + '6'
- if r == 3:
- x = x + '13'
- if r == 4:
- x = x + 'P>'
- if r == 5:
- x = x + '|:'
- if r == 6:
- x = x + '!3'
- if r == 7:
- x = x + '(3'
- if r == 8:
- x = x + '/3'
- if r == 9:
- x = x + ')3'
- if r == 10:
- x = x + '|3'
- elif (phrase[i] == 'C') or (phrase[i] == 'c'):
- r = randrange(1,3)
- if r == 1:
- x = x + '['
- if r == 2:
- x = x + '('
- if r == 3:
- x = x + '<'
- elif (phrase[i] == 'D') or (phrase[i] == 'd'):
- r = randrange(1,8)
- if r == 1:
- x = x + ')'
- if r == 2:
- x = x + '[)'
- if r == 3:
- x = x + 'I>'
- if r == 4:
- x = x + '|>'
- if r == 5:
- x = x + '?'
- if r == 6:
- x = x + 'T)'
- if r == 7:
- x = x + '|)'
- if r == 8:
- x = x + '0'
- elif (phrase[i] == 'E') or (phrase[i] == 'e'):
- r = randrange(1,4)
- if r == 1:
- x = x + '3'
- if r == 2:
- x = x + '&'
- if r == 3:
- x = x + '[-'
- if r == 4:
- x = x + '|=-'
- elif (phrase[i] == 'F') or (phrase[i] == 'f'):
- r = randrange(1,4)
- if r == 1:
- x = x + '|='
- if r == 2:
- x = x + '|#'
- if r == 3:
- x = x + 'ph'
- if r == 4:
- x = x + '/='
- elif (phrase[i] == 'G') or (phrase[i] == 'g'):
- r = randrange(1,7)
- if r == 1:
- x = x + '6'
- if r == 2:
- x = x + '&'
- if r == 3:
- x = x + '(_+'
- if r == 4:
- x = x + '9'
- if r == 5:
- x = x + 'C-'
- if r == 6:
- x = x + 'gee'
- if r == 7:
- x = x + '(y,'
- elif (phrase[i] == 'H') or (phrase[i] == 'h'):
- r = randrange(1,12)
- if r == 1:
- x = x + '#'
- if r == 2:
- x = x + '/-/'
- if r == 3:
- x = x + '[-]'
- if r == 4:
- x = x + ']-['
- if r == 5:
- x = x + ')-('
- if r == 6:
- x = x + '(-)'
- if r == 7:
- x = x + ':-:'
- if r == 8:
- x = x + '|~|'
- if r == 9:
- x = x + '|-|'
- if r == 10:
- x = x + ']~['
- if r == 11:
- x = x + '}{'
- if r == 12:
- x = x + '}-{'
- elif (phrase[i] == 'I') or (phrase[i] == 'i'):
- r = randrange(1,6)
- if r == 1:
- x = x + '1'
- if r == 2:
- x = x + '!'
- if r == 3:
- x = x + '|'
- if r == 4:
- x = x + 'eye'
- if r == 5:
- x = x + '3y3'
- if r == 6:
- x = x + ']'
- elif (phrase[i] == 'J') or (phrase[i] == 'j'):
- r = randrange(1,4)
- if r == 1:
- x = x + '_|'
- if r == 2:
- x = x + '_/'
- if r == 3:
- x = x + '</'
- if r == 4:
- x = x + '(/'
- elif (phrase[i] == 'K') or (phrase[i] == 'k'):
- r = randrange(1,4)
- if r == 1:
- x = x + '|{'
- if r == 2:
- x = x + '|<'
- elif (phrase[i] == 'L') or (phrase[i] == 'l'):
- r = randrange(1,5)
- if r == 1:
- x = x + '1'
- if r == 2:
- x = x + '7'
- if r == 3:
- x = x + '1_'
- if r == 4:
- x = x + '|'
- if r == 5:
- x = x + '|_'
- elif (phrase[i] == 'M') or (phrase[i] == 'm'):
- r = randrange(1,14)
- if r == 1:
- x = x + '|v|'
- if r == 2:
- x = x + '[V]'
- if r == 3:
- x = x + '{V}'
- if r == 4:
- x = x + '|\\/]'
- if r == 5:
- x = x + '/\\/\\'
- if r == 6:
- x = x + '(u)'
- if r == 7:
- x = x + '(v)'
- if r == 8:
- x = x + '(\\/)'
- if r == 9:
- x = x + '/|\\'
- if r == 10:
- x = x + '^^'
- if r == 11:
- x = x + '/|/|'
- if r == 12:
- x = x + '//.'
- if r == 13:
- x = x + '.\\\\'
- if r == 14:
- x = x + '/^^\\'
- elif (phrase[i] == 'N') or (phrase[i] == 'n'):
- r = randrange(1,10)
- if r == 1:
- x = x + '^/'
- if r == 2:
- x = x + '|v'
- if r == 3:
- x = x + '|\\|'
- if r == 4:
- x = x + '/\\/'
- if r == 5:
- x = x + '[\\]'
- if r == 6:
- x = x + '<\\>'
- if r == 7:
- x = x + '{\\}'
- if r == 8:
- x = x + '[]\\'
- if r == 9:
- x = x + '// []'
- if r == 10:
- x = x + '/V'
- elif (phrase[i] == 'O') or (phrase[i] == 'o'):
- r = randrange(1,4)
- if r == 1:
- x = x + '0'
- if r == 2:
- x = x + '()'
- if r == 3:
- x = x + 'oh'
- if r == 4:
- x = x + '[]'
- elif (phrase[i] == 'P') or (phrase[i] == 'p'):
- r = randrange(1,8)
- if r == 1:
- x = x + '|*'
- if r == 2:
- x = x + '|o'
- if r == 3:
- x = x + '|^(o)'
- if r == 4:
- x = x + '|>'
- if r == 5:
- x = x + '|"'
- if r == 6:
- x = x + '9'
- if r == 7:
- x = x + '[]D'
- if r == 8:
- x = x + '|7'
- elif (phrase[i] == 'Q') or (phrase[i] == 'q'):
- r = randrange(1,4)
- if r == 1:
- x = x + '(_,)'
- if r == 2:
- x = x + '()_'
- if r == 3:
- x = x + '0_'
- if r == 4:
- x = x + '<|'
- elif (phrase[i] == 'R') or (phrase[i] == 'r'):
- r = randrange(1,8)
- if r == 1:
- x = x + '2'
- if r == 2:
- x = x + '|?'
- if r == 3:
- x = x + '/2'
- if r == 4:
- x = x + '|^'
- if r == 5:
- x = x + 'lz'
- if r == 6:
- x = x + '[z'
- if r == 7:
- x = x + '12'
- if r == 8:
- x = x + '|2'
- elif (phrase[i] == 'S') or (phrase[i] == 's'):
- r = randrange(1,5)
- if r == 1:
- x = x + '5'
- if r == 2:
- x = x + '$'
- if r == 3:
- x = x + 'z'
- if r == 4:
- x = x + 'ehs'
- if r == 5:
- x = x + 'es'
- elif (phrase[i] == 'T') or (phrase[i] == 't'):
- r = randrange(1,4)
- if r == 1:
- x = x + '7'
- if r == 2:
- x = x + '+'
- if r == 3:
- x = x + '-|-'
- if r == 4:
- x = x + '1'
- elif (phrase[i] == 'U') or (phrase[i] == 'u'):
- r = randrange(1,4)
- if r == 1:
- x = x + '(_)'
- if r == 1:
- x = x + '|_|'
- if r == 3:
- x = x + 'v'
- if r == 4:
- x = x + ']_|'
- elif (phrase[i] == 'V') or (phrase[i] == 'v'):
- r = randrange(1,3)
- if r == 1:
- x = x + '\\/'
- if r == 1:
- x = x + '1/'
- if r == 1:
- x = x + '|/'
- elif (phrase[i] == 'W') or (phrase[i] == 'w'):
- r = randrange(1,9)
- if r == 1:
- x = x + '\\/\\/'
- if r == 2:
- x = x + 'vv'
- if r == 3:
- x = x + '\\^/'
- if r == 4:
- x = x + '(n)'
- if r == 5:
- x = x + '\\V/'
- if r == 6:
- x = x + '\\X/'
- if r == 7:
- x = x + '\\|/'
- if r == 8:
- x = x + '\\_|_/'
- if r == 9:
- x = x + '\\_:_/'
- elif (phrase[i] == 'X') or (phrase[i] == 'x'):
- r = randrange(1,4)
- if r == 1:
- x = x + '><'
- if r == 2:
- x = x + '}{'
- if r == 3:
- x = x + 'ecks'
- if r == 4:
- x = x + ')('
- elif (phrase[i] == 'Y') or (phrase[i] == 'y'):
- r = randrange(1,2)
- if r == 1:
- x = x + '\'/'
- if r == 2:
- x = x + ''
- elif (phrase[i] == 'Z') or (phrase[i] == 'z'):
- r = randrange(1,7)
- if r == 1:
- x = x + '2'
- if r == 2:
- x = x + '7_'
- if r == 3:
- x = x + '~/_'
- if r == 4:
- x = x + '%'
- if r == 5:
- x = x + '>_'
- if r == 6:
- x = x + '-\\_'
- if r == 7:
- x = x + '\'/_'
- elif (phrase[i] == ' '):
- x = x + ' '
- else:
- x = x + phrase[i]
- i = i + 1
-
- print x
#!/usr/bin/python
phrase = raw_input()
from random import randrange
x = ''
i = 0
while i < len(phrase):
if (phrase[i] == 'A') or (phrase[i] == 'a'):
r = randrange(1,7)
if r == 1:
x = x + '4'
if r == 2:
x = x + '/\\'
if r == 3:
x = x + '@'
if r == 4:
x = x + '^'
if r == 5:
x = x + 'aye'
if r == 6:
x = x + '/-\\'
if r == 7:
x = x + '|-\\'
elif (phrase[i] == 'B') or (phrase[i] == 'b'):
r = randrange(1,10)
if r == 1:
x = x + '8'
if r == 2:
x = x + '6'
if r == 3:
x = x + '13'
if r == 4:
x = x + 'P>'
if r == 5:
x = x + '|:'
if r == 6:
x = x + '!3'
if r == 7:
x = x + '(3'
if r == 8:
x = x + '/3'
if r == 9:
x = x + ')3'
if r == 10:
x = x + '|3'
elif (phrase[i] == 'C') or (phrase[i] == 'c'):
r = randrange(1,3)
if r == 1:
x = x + '['
if r == 2:
x = x + '('
if r == 3:
x = x + '<'
elif (phrase[i] == 'D') or (phrase[i] == 'd'):
r = randrange(1,8)
if r == 1:
x = x + ')'
if r == 2:
x = x + '[)'
if r == 3:
x = x + 'I>'
if r == 4:
x = x + '|>'
if r == 5:
x = x + '?'
if r == 6:
x = x + 'T)'
if r == 7:
x = x + '|)'
if r == 8:
x = x + '0'
elif (phrase[i] == 'E') or (phrase[i] == 'e'):
r = randrange(1,4)
if r == 1:
x = x + '3'
if r == 2:
x = x + '&'
if r == 3:
x = x + '[-'
if r == 4:
x = x + '|=-'
elif (phrase[i] == 'F') or (phrase[i] == 'f'):
r = randrange(1,4)
if r == 1:
x = x + '|='
if r == 2:
x = x + '|#'
if r == 3:
x = x + 'ph'
if r == 4:
x = x + '/='
elif (phrase[i] == 'G') or (phrase[i] == 'g'):
r = randrange(1,7)
if r == 1:
x = x + '6'
if r == 2:
x = x + '&'
if r == 3:
x = x + '(_+'
if r == 4:
x = x + '9'
if r == 5:
x = x + 'C-'
if r == 6:
x = x + 'gee'
if r == 7:
x = x + '(y,'
elif (phrase[i] == 'H') or (phrase[i] == 'h'):
r = randrange(1,12)
if r == 1:
x = x + '#'
if r == 2:
x = x + '/-/'
if r == 3:
x = x + '[-]'
if r == 4:
x = x + ']-['
if r == 5:
x = x + ')-('
if r == 6:
x = x + '(-)'
if r == 7:
x = x + ':-:'
if r == 8:
x = x + '|~|'
if r == 9:
x = x + '|-|'
if r == 10:
x = x + ']~['
if r == 11:
x = x + '}{'
if r == 12:
x = x + '}-{'
elif (phrase[i] == 'I') or (phrase[i] == 'i'):
r = randrange(1,6)
if r == 1:
x = x + '1'
if r == 2:
x = x + '!'
if r == 3:
x = x + '|'
if r == 4:
x = x + 'eye'
if r == 5:
x = x + '3y3'
if r == 6:
x = x + ']'
elif (phrase[i] == 'J') or (phrase[i] == 'j'):
r = randrange(1,4)
if r == 1:
x = x + '_|'
if r == 2:
x = x + '_/'
if r == 3:
x = x + '</'
if r == 4:
x = x + '(/'
elif (phrase[i] == 'K') or (phrase[i] == 'k'):
r = randrange(1,4)
if r == 1:
x = x + '|{'
if r == 2:
x = x + '|<'
elif (phrase[i] == 'L') or (phrase[i] == 'l'):
r = randrange(1,5)
if r == 1:
x = x + '1'
if r == 2:
x = x + '7'
if r == 3:
x = x + '1_'
if r == 4:
x = x + '|'
if r == 5:
x = x + '|_'
elif (phrase[i] == 'M') or (phrase[i] == 'm'):
r = randrange(1,14)
if r == 1:
x = x + '|v|'
if r == 2:
x = x + '[V]'
if r == 3:
x = x + '{V}'
if r == 4:
x = x + '|\\/]'
if r == 5:
x = x + '/\\/\\'
if r == 6:
x = x + '(u)'
if r == 7:
x = x + '(v)'
if r == 8:
x = x + '(\\/)'
if r == 9:
x = x + '/|\\'
if r == 10:
x = x + '^^'
if r == 11:
x = x + '/|/|'
if r == 12:
x = x + '//.'
if r == 13:
x = x + '.\\\\'
if r == 14:
x = x + '/^^\\'
elif (phrase[i] == 'N') or (phrase[i] == 'n'):
r = randrange(1,10)
if r == 1:
x = x + '^/'
if r == 2:
x = x + '|v'
if r == 3:
x = x + '|\\|'
if r == 4:
x = x + '/\\/'
if r == 5:
x = x + '[\\]'
if r == 6:
x = x + '<\\>'
if r == 7:
x = x + '{\\}'
if r == 8:
x = x + '[]\\'
if r == 9:
x = x + '// []'
if r == 10:
x = x + '/V'
elif (phrase[i] == 'O') or (phrase[i] == 'o'):
r = randrange(1,4)
if r == 1:
x = x + '0'
if r == 2:
x = x + '()'
if r == 3:
x = x + 'oh'
if r == 4:
x = x + '[]'
elif (phrase[i] == 'P') or (phrase[i] == 'p'):
r = randrange(1,8)
if r == 1:
x = x + '|*'
if r == 2:
x = x + '|o'
if r == 3:
x = x + '|^(o)'
if r == 4:
x = x + '|>'
if r == 5:
x = x + '|"'
if r == 6:
x = x + '9'
if r == 7:
x = x + '[]D'
if r == 8:
x = x + '|7'
elif (phrase[i] == 'Q') or (phrase[i] == 'q'):
r = randrange(1,4)
if r == 1:
x = x + '(_,)'
if r == 2:
x = x + '()_'
if r == 3:
x = x + '0_'
if r == 4:
x = x + '<|'
elif (phrase[i] == 'R') or (phrase[i] == 'r'):
r = randrange(1,8)
if r == 1:
x = x + '2'
if r == 2:
x = x + '|?'
if r == 3:
x = x + '/2'
if r == 4:
x = x + '|^'
if r == 5:
x = x + 'lz'
if r == 6:
x = x + '[z'
if r == 7:
x = x + '12'
if r == 8:
x = x + '|2'
elif (phrase[i] == 'S') or (phrase[i] == 's'):
r = randrange(1,5)
if r == 1:
x = x + '5'
if r == 2:
x = x + '$'
if r == 3:
x = x + 'z'
if r == 4:
x = x + 'ehs'
if r == 5:
x = x + 'es'
elif (phrase[i] == 'T') or (phrase[i] == 't'):
r = randrange(1,4)
if r == 1:
x = x + '7'
if r == 2:
x = x + '+'
if r == 3:
x = x + '-|-'
if r == 4:
x = x + '1'
elif (phrase[i] == 'U') or (phrase[i] == 'u'):
r = randrange(1,4)
if r == 1:
x = x + '(_)'
if r == 1:
x = x + '|_|'
if r == 3:
x = x + 'v'
if r == 4:
x = x + ']_|'
elif (phrase[i] == 'V') or (phrase[i] == 'v'):
r = randrange(1,3)
if r == 1:
x = x + '\\/'
if r == 1:
x = x + '1/'
if r == 1:
x = x + '|/'
elif (phrase[i] == 'W') or (phrase[i] == 'w'):
r = randrange(1,9)
if r == 1:
x = x + '\\/\\/'
if r == 2:
x = x + 'vv'
if r == 3:
x = x + '\\^/'
if r == 4:
x = x + '(n)'
if r == 5:
x = x + '\\V/'
if r == 6:
x = x + '\\X/'
if r == 7:
x = x + '\\|/'
if r == 8:
x = x + '\\_|_/'
if r == 9:
x = x + '\\_:_/'
elif (phrase[i] == 'X') or (phrase[i] == 'x'):
r = randrange(1,4)
if r == 1:
x = x + '><'
if r == 2:
x = x + '}{'
if r == 3:
x = x + 'ecks'
if r == 4:
x = x + ')('
elif (phrase[i] == 'Y') or (phrase[i] == 'y'):
r = randrange(1,2)
if r == 1:
x = x + '\'/'
if r == 2:
x = x + ''
elif (phrase[i] == 'Z') or (phrase[i] == 'z'):
r = randrange(1,7)
if r == 1:
x = x + '2'
if r == 2:
x = x + '7_'
if r == 3:
x = x + '~/_'
if r == 4:
x = x + '%'
if r == 5:
x = x + '>_'
if r == 6:
x = x + '-\\_'
if r == 7:
x = x + '\'/_'
elif (phrase[i] == ' '):
x = x + ' '
else:
x = x + phrase[i]
i = i + 1
print x
Conclusion
Voilà ! N'hésitez pas à poster des commentaires pour m'aider à améliorer cette source !
Historique
- 03 novembre 2008 14:10:16 :
- Correction d'un elif
- 03 novembre 2008 14:11:51 :
- Modif d'un elif
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Changer le nom d'une variable ds une boucle [ par Bl0tCh ]
Bonjour à tous,Mon probleme aujourd'hui est de changer le NOM d'une variabale :i=0while 1: i=i+1 exemple='test' print exempleEn fait je voudr
Problème d'encodage [ par tomix81 ]
Salut, J'ai un problème avec les caractères speciaux. Par exemple au lieu d'avoir un caractère comme "é", j'ai le caractère ù en majuscule. J'ai incl
Transformer une liste en chaine de caractères [ par fredouzzz ]
Bonjour, j'ai une liste stockée dans une variable (result_set) j'aimerais convertir cette liste en une chaîne de caractère. Par exemp
Condition ne fonctionne pas [ par Fabrizio001 ]
Bonjour,Je débute (1 semaine )en python et je sollicite votre aide. Voici ce que j'essaye de faire:Je veux contrôler le contenu d'un fichier .txt qui
voir si un caractère a déjà était écrit dans une boucle [ par Lutcho74 ]
Bonjour,Ma question est un peu dans le titre du sujet...Je compte faire un programme qui donne un nombre aléatoire grâce au module random pour ensuite
codage Windows jeu de caractères [ par creaduff ]
Bonjour,Avant tout, précisons que je ne suis pas un aigle en Python ! Voici mon problème:J'ai écrit une petit programme permettant d'accéder à ma boit
chaine de caractères [ par bossou ]
Bonjour.j'ai un fichier texte où je récupère une ligne en faisant une recherche sur un mot.la ligne récupérée contient plusieurs points virgules exemp
Tuto Swinnen : mouvement aléatoire ? [ par nemo43 ]
Bonjour à tous,J'étudie le langage python - c'est un loisir - avec le livre de Gérard Swinnen (comme beaucoup de francophones je pense ). Je bloque su
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|