Commit iniziale con codice di base funzionante.
This commit is contained in:
commit
4015b7bfc2
2 changed files with 62 additions and 0 deletions
22
cifra.py
Normal file
22
cifra.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import string, sys
|
||||
|
||||
def cifra(testo, rotazione = 5):
|
||||
risultato = ''
|
||||
for i in testo.upper():
|
||||
if not i in string.ascii_uppercase:
|
||||
risultato = risultato + i
|
||||
continue
|
||||
indice_c = string.ascii_uppercase.index(i)
|
||||
parziale = indice_c + rotazione
|
||||
if parziale > len(string.ascii_uppercase):
|
||||
parziale = parziale % len(string.ascii_uppercase)
|
||||
|
||||
risultato += string.ascii_uppercase[parziale]
|
||||
|
||||
return risultato
|
||||
|
||||
if __name__ == '__main__':
|
||||
print cifra(sys.argv[1].upper(), 5)
|
Loading…
Add table
Add a link
Reference in a new issue