Commit 753e54f9 authored by Thibaut.Lunet's avatar Thibaut.Lunet
Browse files

TL: added new modifications on python seminar presentation

parent b2fb284c
......@@ -408,24 +408,29 @@ Tuples are lists of fixed size with non-mutable elements
def encodeMsg(msg, offset):
abc = 'abcdefghijklmnopqrstuvwxyz'
abc_code = abc[offset:]+abc[:offset]
dico = dict(zip(abc, abc_code))
# Build a coding dictionary
dico = {}
for i in range(len(abc)):
dico[abc[i]] = abc_code[i]
# Shorter version
# dico = dict(zip(abc, abc_code))
# Translate the message
msg_code = ''
for c in msg:
if c in dico:
msg_code += dico[c]
msg_code += c
msg_code += dico[c] if c in dico else c
# Shorter version
# msg_code = ''.join([dico[c] if c in dico else c for c in msg])
return msg_code
msg_code = encodeMsg("w'nv snvyyv nggraqer", 13)
print(encodeMsg("w'nv snvyyv nggraqer", 13))
\begin{frame}{Exercice 2 : the Caesar cipher}
$\rightarrow$ decode the following message, encrypted with the Caesar cipher with offset $-13$ :
"w'nv snvyyv nggraqer"
......@@ -513,7 +518,7 @@ $\rightarrow$ how to quickly plot the values of a matrix with colorbar ?
from scipy.optimize import curve_fit
... incoming
\begin{frame}{Exercise : curve fitting}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment