4 "signature": "sha256:78e6a962b2bb32da5900535436f656d194701924a6f32591d57f2b5973eb315c"
16 "string.ascii_lowercase"
23 "output_type": "pyout",
26 "'abcdefghijklmnopqrstuvwxyz'"
36 "string.ascii_lowercase[:-2]"
43 "output_type": "pyout",
46 "'abcdefghijklmnopqrstuvwx'"
56 "for i in range(10):\n",
57 " print(i, string.ascii_lowercase[i+2].upper())"
63 "output_type": "stream",
85 "members = ['Freddie', 'Brian', 'Roger', 'John']\n",
86 "tour_lineup = members\n",
87 "tour_lineup[0] = 'Paul'\n",
88 "print(tour_lineup)\n",
95 "output_type": "stream",
98 "['Paul', 'Brian', 'Roger', 'John']\n",
99 "['Paul', 'Brian', 'Roger', 'John']\n"
109 "members = ['Freddie', 'Brian', 'Roger', 'John']\n",
110 "members = ['Paul'] + members"
112 "language": "python",
123 "language": "python",
127 "ename": "IndexError",
128 "evalue": "list index out of range",
129 "output_type": "pyerr",
131 "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
132 "\u001b[1;32m<ipython-input-22-6b5bb11d700b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mmembers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m99\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
133 "\u001b[1;31mIndexError\u001b[0m: list index out of range"
145 "language": "python",
150 "output_type": "pyout",
163 "members = ['Freddie', 'Brian', 'Roger', 'John']\n",
164 "tour_lineup = members\n",
165 "tour_lineup == members"
167 "language": "python",
172 "output_type": "pyout",
185 "tour_lineup = members[:]\n",
186 "tour_lineup == members"
188 "language": "python",
193 "output_type": "pyout",
206 "tour_lineup is members"
208 "language": "python",
213 "output_type": "pyout",
226 "[(a, b, int((a**2 + b**2)**0.5)) \n",
227 " for a in range(1, 20) \n",
228 " for b in range(a, 20) \n",
229 " if int((a**2 + b**2)**0.5) == (a**2 + b**2)**0.5]"
231 "language": "python",
236 "output_type": "pyout",
239 "[(3, 4, 5), (5, 12, 13), (6, 8, 10), (8, 15, 17), (9, 12, 15), (12, 16, 20)]"
250 "for i in (2,4,8,22):\n",
254 "language": "python",
259 "output_type": "pyout",
272 "GRID_STRING = \"\"\"08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\n",
273 "49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00\n",
274 "81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65\n",
275 "52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91\n",
276 "22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80\n",
277 "24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50\n",
278 "32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70\n",
279 "67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21\n",
280 "24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72\n",
281 "21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95\n",
282 "78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92\n",
283 "16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57\n",
284 "86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58\n",
285 "19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40\n",
286 "04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66\n",
287 "88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69\n",
288 "04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36\n",
289 "20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16\n",
290 "20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54\n",
291 "01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48\"\"\"\n",
292 "ROWS = COLUMNS = 20"
294 "language": "python",
304 "for x in range(COLUMNS):\n",
305 " for y in range(ROWS):\n",
306 " gt[(x,y)] = grid_nums[x + y * COLUMNS]\n",
309 "language": "python",
314 "output_type": "pyout",
726 "gt_again = {(x,y): grid_nums[x + y * COLUMNS] \n",
727 " for x in range(ROWS) \n",
728 " for y in range(COLUMNS)}\n",
731 "language": "python",
736 "output_type": "pyout",
749 "grid_nums = [int(n) for n in GRID_STRING.split()]\n",
752 "language": "python",
757 "output_type": "pyout",
1166 "cell_type": "code",
1171 "language": "python",
1176 "output_type": "pyout",
1177 "prompt_number": 32,
1186 "cell_type": "code",
1190 "for rowstart in range(0, ROWS * COLUMNS, COLUMNS):\n",
1191 " g1.append(grid_nums[rowstart:rowstart+COLUMNS])\n",
1194 "language": "python",
1199 "output_type": "pyout",
1200 "prompt_number": 29,
1202 "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
1243 " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
1344 " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
1345 " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
1366 " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
1387 " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
1494 "cell_type": "code",
1497 "g3 = [grid_nums[rowstart:rowstart+COLUMNS] \n",
1498 " for rowstart in range(0, ROWS * COLUMNS, COLUMNS)]\n",
1501 "language": "python",
1506 "output_type": "pyout",
1507 "prompt_number": 45,
1509 "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
1550 " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
1651 " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
1652 " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
1673 " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
1694 " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
1801 "cell_type": "code",
1805 "for rowstart in range(0, ROWS * COLUMNS, COLUMNS):\n",
1806 " g1.append(grid_nums[rowstart:rowstart+COLUMNS])\n",
1809 "language": "python",
1813 "output_type": "stream",
1816 "[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8]\n",
1817 "[49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0]\n",
1818 "[81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65]\n",
1819 "[52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91]\n",
1820 "[22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80]\n",
1821 "[24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50]\n",
1822 "[32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70]\n",
1823 "[67, 26, 20, 68, 2, 62, 12, 20, 95, 63, 94, 39, 63, 8, 40, 91, 66, 49, 94, 21]\n",
1824 "[24, 55, 58, 5, 66, 73, 99, 26, 97, 17, 78, 78, 96, 83, 14, 88, 34, 89, 63, 72]\n",
1825 "[21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95]\n",
1826 "[78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92]\n",
1827 "[16, 39, 5, 42, 96, 35, 31, 47, 55, 58, 88, 24, 0, 17, 54, 24, 36, 29, 85, 57]\n",
1828 "[86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58]\n",
1829 "[19, 80, 81, 68, 5, 94, 47, 69, 28, 73, 92, 13, 86, 52, 17, 77, 4, 89, 55, 40]\n",
1830 "[4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66]\n",
1831 "[88, 36, 68, 87, 57, 62, 20, 72, 3, 46, 33, 67, 46, 55, 12, 32, 63, 93, 53, 69]\n",
1832 "[4, 42, 16, 73, 38, 25, 39, 11, 24, 94, 72, 18, 8, 46, 29, 32, 40, 62, 76, 36]\n",
1833 "[20, 69, 36, 41, 72, 30, 23, 88, 34, 62, 99, 69, 82, 67, 59, 85, 74, 4, 36, 16]\n",
1834 "[20, 73, 35, 29, 78, 31, 90, 1, 74, 31, 49, 71, 48, 86, 81, 16, 23, 57, 5, 54]\n",
1835 "[1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48]\n"
1840 "output_type": "pyout",
1841 "prompt_number": 39,
1843 "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
1884 " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
1985 " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
1986 " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
2007 " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
2028 " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
2135 "cell_type": "code",
2139 "for x in range(COLUMNS):\n",
2140 " for y in range(ROWS):\n",
2141 " g2[(x, y)] = grid_nums[x + y * COLUMNS]\n",
2144 "language": "python",
2149 "output_type": "pyout",
2150 "prompt_number": 30,
2558 "cell_type": "code",
2563 "language": "python",
2568 "output_type": "pyout",
2569 "prompt_number": 35,
2578 "cell_type": "code",
2581 "g3 = [grid_nums[row * COLUMNS:(row+1) * COLUMNS] for row in range(ROWS)]\n",
2584 "language": "python",
2589 "output_type": "pyout",
2590 "prompt_number": 27,
2592 "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
2633 " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
2734 " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
2735 " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
2756 " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
2777 " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
2884 "cell_type": "code",
2887 "g4 = {(x, y): grid_nums[x + y * COLUMNS] \n",
2888 " for x in range(COLUMNS) \n",
2889 " for y in range(ROWS)}\n",
2892 "language": "python",
2897 "output_type": "pyout",
2898 "prompt_number": 63,
3306 "cell_type": "code",
3309 "g4s = {(x, y): int(GRID_STRING[(x + y * COLUMNS) * 3:(x + y * COLUMNS) * 3 + 2]) \n",
3310 " for x in range(COLUMNS) \n",
3311 " for y in range(ROWS)}\n",
3314 "language": "python",
3319 "output_type": "pyout",
3320 "prompt_number": 65,
3728 "cell_type": "code",
3733 "language": "python",
3738 "output_type": "pyout",
3739 "prompt_number": 66,
3748 "cell_type": "code",
3754 "language": "python",
3758 "ename": "KeyError",
3760 "output_type": "pyerr",
3762 "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
3763 "\u001b[1;32m<ipython-input-67-fb0bb5c8abf1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0md\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0md\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m99\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
3764 "\u001b[1;31mKeyError\u001b[0m: 99"
3771 "cell_type": "code",
3774 "import collections\n",
3775 "d = collections.defaultdict(int)\n",
3778 "language": "python",
3783 "output_type": "pyout",
3784 "prompt_number": 69,
3793 "cell_type": "code",
3797 "collections.Counter(l for l in open('sherlock-holmes.txt').read()\n",
3798 " if l in string.ascii_letters)"
3800 "language": "python",
3805 "output_type": "pyout",
3806 "prompt_number": 71,
3808 "Counter({'e': 52876, 't': 37842, 'a': 34376, 'o': 33200, 'n': 28378, 'h': 27803, 's': 26432, 'i': 26366, 'r': 24304, 'd': 18349, 'l': 16854, 'u': 13070, 'm': 11055, 'w': 10508, 'c': 10172, 'y': 8976, 'f': 8785, 'g': 7733, 'p': 6652, 'b': 5883, 'v': 4367, 'I': 3774, 'k': 3465, 'H': 1244, 'T': 1139, 'S': 762, 'A': 761, 'W': 758, 'M': 732, 'x': 541, 'B': 479, 'Y': 455, 'q': 406, 'j': 338, 'C': 327, 'O': 312, 'N': 304, 'L': 291, 'E': 235, 'D': 214, 'R': 204, 'F': 190, 'P': 183, 'G': 154, 'z': 147, 'J': 114, 'V': 85, 'K': 78, 'U': 46, 'Q': 20, 'X': 8, 'Z': 2})"
3815 "cell_type": "code",
3819 " for a in range(1, 21) \n",
3820 " for b in range(a, 21)\n",
3821 " for c in range(b, 21)\n",
3822 " if a**2 + b**2 == c**2]"
3824 "language": "python",
3829 "output_type": "pyout",
3830 "prompt_number": 74,
3832 "[(3, 4, 5), (5, 12, 13), (6, 8, 10), (8, 15, 17), (9, 12, 15), (12, 16, 20)]"
3839 "cell_type": "code",
3844 "language": "python",
3849 "output_type": "pyout",
3850 "prompt_number": 75,
3852 "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
3893 " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
3994 " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
3995 " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
4016 " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
4037 " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
4144 "cell_type": "code",
4147 "[n for row in g1 for n in row]"
4149 "language": "python",
4154 "output_type": "pyout",
4155 "prompt_number": 76,
4563 "cell_type": "code",
4566 "import collections\n",
4568 "collections.Counter(l for l in open('sherlock-holmes.txt').read()\n",
4569 " if l in string.ascii_letters)"
4571 "language": "python",
4576 "output_type": "pyout",
4577 "prompt_number": 51,
4579 "Counter({'e': 52876, 't': 37842, 'a': 34376, 'o': 33200, 'n': 28378, 'h': 27803, 's': 26432, 'i': 26366, 'r': 24304, 'd': 18349, 'l': 16854, 'u': 13070, 'm': 11055, 'w': 10508, 'c': 10172, 'y': 8976, 'f': 8785, 'g': 7733, 'p': 6652, 'b': 5883, 'v': 4367, 'I': 3774, 'k': 3465, 'H': 1244, 'T': 1139, 'S': 762, 'A': 761, 'W': 758, 'M': 732, 'x': 541, 'B': 479, 'Y': 455, 'q': 406, 'j': 338, 'C': 327, 'O': 312, 'N': 304, 'L': 291, 'E': 235, 'D': 214, 'R': 204, 'F': 190, 'P': 183, 'G': 154, 'z': 147, 'J': 114, 'V': 85, 'K': 78, 'U': 46, 'Q': 20, 'X': 8, 'Z': 2})"
4586 "cell_type": "code",
4589 "import collections\n",
4591 "c = collections.Counter(l.lower() for l in open('sherlock-holmes.txt').read()\n",
4592 " if l in string.ascii_letters)\n",
4593 "[(l, c[l]) for l in sorted(c)]"
4595 "language": "python",
4600 "output_type": "pyout",
4601 "prompt_number": 50,
4635 "cell_type": "code",
4639 "import collections\n",
4642 "language": "python",
4648 "cell_type": "code",
4651 "def only_lower_case(str):\n",
4655 "language": "python",
4660 "cell_type": "code",
4663 "words = [line.strip() \n",
4664 " for line in open('/usr/share/dict/british-english').readlines()\n",
4665 " if only_lower_case(line)]\n",
4668 "language": "python",
4673 "output_type": "pyout",
4674 "prompt_number": 57,
4702 "cell_type": "code",
4705 "string.ascii_letters"
4707 "language": "python",
4712 "output_type": "pyout",
4713 "prompt_number": 58,
4715 "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"
4722 "cell_type": "code",
4725 "string.ascii_lowercase"
4727 "language": "python",
4732 "output_type": "pyout",
4733 "prompt_number": 60,
4735 "'abcdefghijklmnopqrstuvwxyz'"
4742 "cell_type": "code",
4745 "string.ascii_uppercase"
4747 "language": "python",
4752 "output_type": "pyout",
4753 "prompt_number": 61,
4755 "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"
4762 "cell_type": "code",
4765 "string.punctuation"
4767 "language": "python",
4772 "output_type": "pyout",
4773 "prompt_number": 62,
4775 "'!\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~'"
4782 "cell_type": "code",
4785 "'b' in string.ascii_lowercase"
4787 "language": "python",
4792 "output_type": "pyout",
4793 "prompt_number": 63,
4802 "cell_type": "code",
4805 "'B' in string.ascii_lowercase"
4807 "language": "python",
4812 "output_type": "pyout",
4813 "prompt_number": 64,
4822 "cell_type": "code",
4825 "[l for l in 'hello']"
4827 "language": "python",
4832 "output_type": "pyout",
4833 "prompt_number": 65,
4835 "['h', 'e', 'l', 'l', 'o']"
4842 "cell_type": "code",
4845 "for l in 'hello':\n",
4848 "language": "python",
4852 "output_type": "stream",
4866 "cell_type": "code",
4869 "'b' not in string.ascii_lowercase"
4871 "language": "python",
4876 "output_type": "pyout",
4877 "prompt_number": 67,
4886 "cell_type": "code",
4889 "'B' not in string.ascii_lowercase"
4891 "language": "python",
4896 "output_type": "pyout",
4897 "prompt_number": 68,
4906 "cell_type": "code",
4909 "language": "python",