Added the first slide
[cipher-training.git] / slides / caesar-encipher.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Title</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6 <style type="text/css">
7 /* Slideshow styles */
8 </style>
9 </head>
10 <body>
11 <textarea id="source">
12
13 class: center, middle
14
15 # Caesar ciphers
16
17 * Letter-by-letter enciphering
18
19 ---
20
21 # The [string module](http://docs.python.org/3.3/library/string.html) is your friend
22
23 ```python
24 import string
25 string.ascii_letters
26 string.ascii_lowercase
27 string.ascii_uppercase
28 string.digits
29 string.punctuation
30 ```
31
32 ---
33
34 # Doctest
35
36 * Why document?
37 * Why test?
38
39 ---
40
41 # The magic doctest incantation
42
43 ```python
44 if __name__ == "__main__":
45 import doctest
46 doctest.testmod()
47 ```
48
49 ---
50
51 # Doing all the letters
52
53 ## Abysmal
54
55 ```python
56 ciphertext = ''
57 for i in range(len(plaintext)):
58 ciphertext += caesar_encipher_letter(plaintext[i], key)
59 ```
60
61 ---
62
63 # Doing all the letters
64
65 ## (Merely) Bad
66
67 ```python
68 ciphertext = ''
69 for p in plaintext:
70 ciphertext += caesar_encipher_letter(p, key)
71 ```
72
73 ---
74
75 # Doing all the letters
76
77 ## Good (but unPythonic)
78
79 ```python
80 ciphertext = map(lambda p: caesar_encipher_letter(p, key), plaintext)
81 ```
82
83 ---
84
85 # Doing all the letters
86
87 ## Best
88
89 ```python
90 ciphertext = [caesar_encipher_letter(p, key) for p in plaintext]
91 ```
92
93
94 </textarea>
95 <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
96 </script>
97 <script type="text/javascript">
98 var slideshow = remark.create();
99 </script>
100 </body>
101 </html>