├── requirements.txt ├── branches.png ├── git_add.png ├── git_clone.png ├── git_fetch.png ├── git_merge.png ├── git_push.png ├── jupyter.png ├── sshkeygen.png ├── git_branch.png ├── git_commit.png ├── git_layout.png ├── git_status.png ├── github_new.png ├── github_ssh.png ├── pandastruct.png ├── cs109gitflow1.png ├── cs109gitflow2.png ├── cs109gitflow3.png ├── git_checkout.png ├── github-forking.png ├── github_branch.png ├── wgi-git-bash.png ├── wgi-usemintty.png ├── github-forking2.png ├── github-forking3.png ├── github-ssh-clone.png ├── mac-git-security.png ├── wgi-defaultlines.png ├── wgi-scarymessage.png ├── github-https-clone.png ├── github_collaborators.png ├── .gitignore ├── README.md ├── git-prompt.sh ├── Lab1-babypython.ipynb └── Lab1-babypython_original.ipynb /requirements.txt: -------------------------------------------------------------------------------- 1 | seaborn 2 | pyquery 3 | beautifulsoup4 4 | -------------------------------------------------------------------------------- /branches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/branches.png -------------------------------------------------------------------------------- /git_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_add.png -------------------------------------------------------------------------------- /git_clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_clone.png -------------------------------------------------------------------------------- /git_fetch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_fetch.png -------------------------------------------------------------------------------- /git_merge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_merge.png -------------------------------------------------------------------------------- /git_push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_push.png -------------------------------------------------------------------------------- /jupyter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/jupyter.png -------------------------------------------------------------------------------- /sshkeygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/sshkeygen.png -------------------------------------------------------------------------------- /git_branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_branch.png -------------------------------------------------------------------------------- /git_commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_commit.png -------------------------------------------------------------------------------- /git_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_layout.png -------------------------------------------------------------------------------- /git_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_status.png -------------------------------------------------------------------------------- /github_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github_new.png -------------------------------------------------------------------------------- /github_ssh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github_ssh.png -------------------------------------------------------------------------------- /pandastruct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/pandastruct.png -------------------------------------------------------------------------------- /cs109gitflow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/cs109gitflow1.png -------------------------------------------------------------------------------- /cs109gitflow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/cs109gitflow2.png -------------------------------------------------------------------------------- /cs109gitflow3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/cs109gitflow3.png -------------------------------------------------------------------------------- /git_checkout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/git_checkout.png -------------------------------------------------------------------------------- /github-forking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github-forking.png -------------------------------------------------------------------------------- /github_branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github_branch.png -------------------------------------------------------------------------------- /wgi-git-bash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/wgi-git-bash.png -------------------------------------------------------------------------------- /wgi-usemintty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/wgi-usemintty.png -------------------------------------------------------------------------------- /github-forking2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github-forking2.png -------------------------------------------------------------------------------- /github-forking3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github-forking3.png -------------------------------------------------------------------------------- /github-ssh-clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github-ssh-clone.png -------------------------------------------------------------------------------- /mac-git-security.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/mac-git-security.png -------------------------------------------------------------------------------- /wgi-defaultlines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/wgi-defaultlines.png -------------------------------------------------------------------------------- /wgi-scarymessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/wgi-scarymessage.png -------------------------------------------------------------------------------- /github-https-clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github-https-clone.png -------------------------------------------------------------------------------- /github_collaborators.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs109/2015lab1/master/github_collaborators.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | 59 | #Ipython 60 | .ipynb_checkpoints/ 61 | # Created by .ignore support plugin (hsz.mobi) 62 | ### OSX template 63 | .DS_Store 64 | .AppleDouble 65 | .LSOverride 66 | 67 | # Icon must end with two \r 68 | Icon 69 | 70 | # Thumbnails 71 | ._* 72 | 73 | # Files that might appear in the root of a volume 74 | .DocumentRevisions-V100 75 | .fseventsd 76 | .Spotlight-V100 77 | .TemporaryItems 78 | .Trashes 79 | .VolumeIcon.icns 80 | 81 | # Directories potentially created on remote AFP share 82 | .AppleDB 83 | .AppleDesktop 84 | Network Trash Folder 85 | Temporary Items 86 | .apdisk 87 | 88 | #Temporary data 89 | tempdata/ 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2015lab1 2 | 3 | [![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/repo/cs109/2015lab1) 4 | 5 | Lets talk a bit about how labs and sections work in cs109: 6 | 7 | 1. Lab Notebooks are made available every Thursday evening. 8 | 2. Lab Videos (which may not cover everything in the notebooks) are made available every Friday as well 9 | 3. In sections starting Monday morning, and running upto the next Friday, your TA will present part of the lab to you. You ought to have looked at and perhaps tried the lab over the previous weekend, and your section might reach a consensus on what you'd like your TF to focus on: please communicate this. 10 | 11 | (Sections are 2 hours long. The first hour will be spent going over the lab, while the second if an office hour, where you can ask your TA questions about the homework, the lectures, the subject matter, and even the lab). 12 | 13 | The labs will be made available on public github repositories, with naming schemes like `cs109/2015lab1`. 14 | 15 | This is how you ought to work with them (our github tutorial has an example of this process on the `cs109/testing` repository): 16 | 17 | 1. First fork the lab from the github web interface. For example, the first lab is at: https://github.com/cs109/2015lab1 . The fork button is at the upper right corner of the page. Press it. 18 | 2. When it asks you where to fork the lab, choose your own github userid. The web interface will then take you to the web page for your fork. Mine is at: https://github.com/rahuldave/2015lab1 . 19 | 3. Now look for the clone url at the bottom right of the page. If you set up your ssh keys, use the ssh url, else use the https url. Mine are `git@github.com:rahuldave/2015lab1.git` and `https://github.com/rahuldave/2015lab1.git` respectively. 20 | 4. Clone your fork down to your machine by obtaining a terminal (`/Applications/Utilities/Terminal.app` or equivalent on mac and `git-bash.exe` on windows). Change (`cd`) into an appropriate folder and clone by doing `git clone url` where the `url` is the one in step 3. 21 | 5. Add a remote for the original repository that you forked from. We'll call this remote `course`. The command for this, for example, for the first lab is: `git remote add course git@github.com:cs109/2015lab1.git` or `git remote add course https://github.com/cs109/2015lab1.git` 22 | 6. Now you have a local repository. Start the ipython notebook in the repository and run the labs. DO NOT run the notebooks ending in `_original.ipynb`. These are simply copies of the labs. We made these copies so that you can update them from our `course` remote in case we make any changes. 23 | 24 | For Lab 1 I'd start with pythonpandas, followed by babypython, and finally git. The git notebook can be run under the ipython notebook. But the git commands can also be run directly on a terminal, which is probably the best place to do them...you can keep the notebook on the side to read as you follow along). So after once having read the tutorial, as described earlier, you now get to work through it. 25 | 26 | When you follow along, you can add in your own notes, and try your own variations. As you are doing this, dont forget to continue doing the "add/commit/push" cycle, so that you save and version your changes, and push them to your fork. This typically looks like: 27 | - git add . 28 | - git commit -a 29 | - git push 30 | 31 | In case we make changes, you can incorporate them into your repo by doing: `git fetch course; git checkout course/master -- labname_original.ipynb` where `labname.ipynb` is the lab in question. An "add/commit/push" cycle will make sure these changes go into your fork as well. If you intend to work on the changed file, simply copy the file to another one and work on it. Or you could make a new branch. Remember that this fork is YOUR repository, and you can do to it what you like. 32 | 33 | The diagram below should help elucidate the above and serve as a command cheat-sheet. 34 | 35 | ![homework](cs109gitflow3.png) 36 | 37 | -------------------------------------------------------------------------------- /git-prompt.sh: -------------------------------------------------------------------------------- 1 | # bash/zsh git prompt support 2 | # 3 | # Copyright (C) 2006,2007 Shawn O. Pearce 4 | # Distributed under the GNU General Public License, version 2.0. 5 | # 6 | # This script allows you to see repository status in your prompt. 7 | # 8 | # To enable: 9 | # 10 | # 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). 11 | # 2) Add the following line to your .bashrc/.zshrc: 12 | # source ~/.git-prompt.sh 13 | # 3a) Change your PS1 to call __git_ps1 as 14 | # command-substitution: 15 | # Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' 16 | # ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' 17 | # the optional argument will be used as format string. 18 | # 3b) Alternatively, for a slightly faster prompt, __git_ps1 can 19 | # be used for PROMPT_COMMAND in Bash or for precmd() in Zsh 20 | # with two parameters,
 and , which are strings
 21 | #        you would put in $PS1 before and after the status string
 22 | #        generated by the git-prompt machinery.  e.g.
 23 | #        Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
 24 | #          will show username, at-sign, host, colon, cwd, then
 25 | #          various status string, followed by dollar and SP, as
 26 | #          your prompt.
 27 | #        ZSH:  precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
 28 | #          will show username, pipe, then various status string,
 29 | #          followed by colon, cwd, dollar and SP, as your prompt.
 30 | #        Optionally, you can supply a third argument with a printf
 31 | #        format string to finetune the output of the branch status
 32 | #
 33 | # The repository status will be displayed only if you are currently in a
 34 | # git repository. The %s token is the placeholder for the shown status.
 35 | #
 36 | # The prompt status always includes the current branch name.
 37 | #
 38 | # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
 39 | # unstaged (*) and staged (+) changes will be shown next to the branch
 40 | # name.  You can configure this per-repository with the
 41 | # bash.showDirtyState variable, which defaults to true once
 42 | # GIT_PS1_SHOWDIRTYSTATE is enabled.
 43 | #
 44 | # You can also see if currently something is stashed, by setting
 45 | # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
 46 | # then a '$' will be shown next to the branch name.
 47 | #
 48 | # If you would like to see if there're untracked files, then you can set
 49 | # GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
 50 | # files, then a '%' will be shown next to the branch name.  You can
 51 | # configure this per-repository with the bash.showUntrackedFiles
 52 | # variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is
 53 | # enabled.
 54 | #
 55 | # If you would like to see the difference between HEAD and its upstream,
 56 | # set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates you are behind, ">"
 57 | # indicates you are ahead, "<>" indicates you have diverged and "="
 58 | # indicates that there is no difference. You can further control
 59 | # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list
 60 | # of values:
 61 | #
 62 | #     verbose       show number of commits ahead/behind (+/-) upstream
 63 | #     name          if verbose, then also show the upstream abbrev name
 64 | #     legacy        don't use the '--count' option available in recent
 65 | #                   versions of git-rev-list
 66 | #     git           always compare HEAD to @{upstream}
 67 | #     svn           always compare HEAD to your SVN upstream
 68 | #
 69 | # You can change the separator between the branch name and the above
 70 | # state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
 71 | # is SP.
 72 | #
 73 | # By default, __git_ps1 will compare HEAD to your SVN upstream if it can
 74 | # find one, or @{upstream} otherwise.  Once you have set
 75 | # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
 76 | # setting the bash.showUpstream config variable.
 77 | #
 78 | # If you would like to see more information about the identity of
 79 | # commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
 80 | # to one of these values:
 81 | #
 82 | #     contains      relative to newer annotated tag (v1.6.3.2~35)
 83 | #     branch        relative to newer tag or branch (master~4)
 84 | #     describe      relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
 85 | #     default       exactly matching tag
 86 | #
 87 | # If you would like a colored hint about the current dirty state, set
 88 | # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
 89 | # the colored output of "git status -sb" and are available only when
 90 | # using __git_ps1 for PROMPT_COMMAND or precmd.
 91 | #
 92 | # If you would like __git_ps1 to do nothing in the case when the current
 93 | # directory is set up to be ignored by git, then set
 94 | # GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
 95 | # repository level by setting bash.hideIfPwdIgnored to "false".
 96 | 
 97 | # check whether printf supports -v
 98 | __git_printf_supports_v=
 99 | printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
100 | 
101 | # stores the divergence from upstream in $p
102 | # used by GIT_PS1_SHOWUPSTREAM
103 | __git_ps1_show_upstream ()
104 | {
105 | 	local key value
106 | 	local svn_remote svn_url_pattern count n
107 | 	local upstream=git legacy="" verbose="" name=""
108 | 
109 | 	svn_remote=()
110 | 	# get some config options from git-config
111 | 	local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
112 | 	while read -r key value; do
113 | 		case "$key" in
114 | 		bash.showupstream)
115 | 			GIT_PS1_SHOWUPSTREAM="$value"
116 | 			if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
117 | 				p=""
118 | 				return
119 | 			fi
120 | 			;;
121 | 		svn-remote.*.url)
122 | 			svn_remote[$((${#svn_remote[@]} + 1))]="$value"
123 | 			svn_url_pattern="$svn_url_pattern\\|$value"
124 | 			upstream=svn+git # default upstream is SVN if available, else git
125 | 			;;
126 | 		esac
127 | 	done <<< "$output"
128 | 
129 | 	# parse configuration values
130 | 	for option in ${GIT_PS1_SHOWUPSTREAM}; do
131 | 		case "$option" in
132 | 		git|svn) upstream="$option" ;;
133 | 		verbose) verbose=1 ;;
134 | 		legacy)  legacy=1  ;;
135 | 		name)    name=1 ;;
136 | 		esac
137 | 	done
138 | 
139 | 	# Find our upstream
140 | 	case "$upstream" in
141 | 	git)    upstream="@{upstream}" ;;
142 | 	svn*)
143 | 		# get the upstream from the "git-svn-id: ..." in a commit message
144 | 		# (git-svn uses essentially the same procedure internally)
145 | 		local -a svn_upstream
146 | 		svn_upstream=($(git log --first-parent -1 \
147 | 					--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
148 | 		if [[ 0 -ne ${#svn_upstream[@]} ]]; then
149 | 			svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}
150 | 			svn_upstream=${svn_upstream%@*}
151 | 			local n_stop="${#svn_remote[@]}"
152 | 			for ((n=1; n <= n_stop; n++)); do
153 | 				svn_upstream=${svn_upstream#${svn_remote[$n]}}
154 | 			done
155 | 
156 | 			if [[ -z "$svn_upstream" ]]; then
157 | 				# default branch name for checkouts with no layout:
158 | 				upstream=${GIT_SVN_ID:-git-svn}
159 | 			else
160 | 				upstream=${svn_upstream#/}
161 | 			fi
162 | 		elif [[ "svn+git" = "$upstream" ]]; then
163 | 			upstream="@{upstream}"
164 | 		fi
165 | 		;;
166 | 	esac
167 | 
168 | 	# Find how many commits we are ahead/behind our upstream
169 | 	if [[ -z "$legacy" ]]; then
170 | 		count="$(git rev-list --count --left-right \
171 | 				"$upstream"...HEAD 2>/dev/null)"
172 | 	else
173 | 		# produce equivalent output to --count for older versions of git
174 | 		local commits
175 | 		if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
176 | 		then
177 | 			local commit behind=0 ahead=0
178 | 			for commit in $commits
179 | 			do
180 | 				case "$commit" in
181 | 				"<"*) ((behind++)) ;;
182 | 				*)    ((ahead++))  ;;
183 | 				esac
184 | 			done
185 | 			count="$behind	$ahead"
186 | 		else
187 | 			count=""
188 | 		fi
189 | 	fi
190 | 
191 | 	# calculate the result
192 | 	if [[ -z "$verbose" ]]; then
193 | 		case "$count" in
194 | 		"") # no upstream
195 | 			p="" ;;
196 | 		"0	0") # equal to upstream
197 | 			p="=" ;;
198 | 		"0	"*) # ahead of upstream
199 | 			p=">" ;;
200 | 		*"	0") # behind upstream
201 | 			p="<" ;;
202 | 		*)	    # diverged from upstream
203 | 			p="<>" ;;
204 | 		esac
205 | 	else
206 | 		case "$count" in
207 | 		"") # no upstream
208 | 			p="" ;;
209 | 		"0	0") # equal to upstream
210 | 			p=" u=" ;;
211 | 		"0	"*) # ahead of upstream
212 | 			p=" u+${count#0	}" ;;
213 | 		*"	0") # behind upstream
214 | 			p=" u-${count%	0}" ;;
215 | 		*)	    # diverged from upstream
216 | 			p=" u+${count#*	}-${count%	*}" ;;
217 | 		esac
218 | 		if [[ -n "$count" && -n "$name" ]]; then
219 | 			__git_ps1_upstream_name=$(git rev-parse \
220 | 				--abbrev-ref "$upstream" 2>/dev/null)
221 | 			if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
222 | 				p="$p \${__git_ps1_upstream_name}"
223 | 			else
224 | 				p="$p ${__git_ps1_upstream_name}"
225 | 				# not needed anymore; keep user's
226 | 				# environment clean
227 | 				unset __git_ps1_upstream_name
228 | 			fi
229 | 		fi
230 | 	fi
231 | 
232 | }
233 | 
234 | # Helper function that is meant to be called from __git_ps1.  It
235 | # injects color codes into the appropriate gitstring variables used
236 | # to build a gitstring.
237 | __git_ps1_colorize_gitstring ()
238 | {
239 | 	if [[ -n ${ZSH_VERSION-} ]]; then
240 | 		local c_red='%F{red}'
241 | 		local c_green='%F{green}'
242 | 		local c_lblue='%F{blue}'
243 | 		local c_clear='%f'
244 | 	else
245 | 		# Using \[ and \] around colors is necessary to prevent
246 | 		# issues with command line editing/browsing/completion!
247 | 		local c_red='\[\e[31m\]'
248 | 		local c_green='\[\e[32m\]'
249 | 		local c_lblue='\[\e[1;34m\]'
250 | 		local c_clear='\[\e[0m\]'
251 | 	fi
252 | 	local bad_color=$c_red
253 | 	local ok_color=$c_green
254 | 	local flags_color="$c_lblue"
255 | 
256 | 	local branch_color=""
257 | 	if [ $detached = no ]; then
258 | 		branch_color="$ok_color"
259 | 	else
260 | 		branch_color="$bad_color"
261 | 	fi
262 | 	c="$branch_color$c"
263 | 
264 | 	z="$c_clear$z"
265 | 	if [ "$w" = "*" ]; then
266 | 		w="$bad_color$w"
267 | 	fi
268 | 	if [ -n "$i" ]; then
269 | 		i="$ok_color$i"
270 | 	fi
271 | 	if [ -n "$s" ]; then
272 | 		s="$flags_color$s"
273 | 	fi
274 | 	if [ -n "$u" ]; then
275 | 		u="$bad_color$u"
276 | 	fi
277 | 	r="$c_clear$r"
278 | }
279 | 
280 | __git_eread ()
281 | {
282 | 	local f="$1"
283 | 	shift
284 | 	test -r "$f" && read "$@" <"$f"
285 | }
286 | 
287 | # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
288 | # when called from PS1 using command substitution
289 | # in this mode it prints text to add to bash PS1 prompt (includes branch name)
290 | #
291 | # __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc)
292 | # in that case it _sets_ PS1. The arguments are parts of a PS1 string.
293 | # when two arguments are given, the first is prepended and the second appended
294 | # to the state string when assigned to PS1.
295 | # The optional third parameter will be used as printf format string to further
296 | # customize the output of the git-status string.
297 | # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
298 | __git_ps1 ()
299 | {
300 | 	# preserve exit status
301 | 	local exit=$?
302 | 	local pcmode=no
303 | 	local detached=no
304 | 	local ps1pc_start='\u@\h:\w '
305 | 	local ps1pc_end='\$ '
306 | 	local printf_format=' (%s)'
307 | 
308 | 	case "$#" in
309 | 		2|3)	pcmode=yes
310 | 			ps1pc_start="$1"
311 | 			ps1pc_end="$2"
312 | 			printf_format="${3:-$printf_format}"
313 | 			# set PS1 to a plain prompt so that we can
314 | 			# simply return early if the prompt should not
315 | 			# be decorated
316 | 			PS1="$ps1pc_start$ps1pc_end"
317 | 		;;
318 | 		0|1)	printf_format="${1:-$printf_format}"
319 | 		;;
320 | 		*)	return $exit
321 | 		;;
322 | 	esac
323 | 
324 | 	# ps1_expanded:  This variable is set to 'yes' if the shell
325 | 	# subjects the value of PS1 to parameter expansion:
326 | 	#
327 | 	#   * bash does unless the promptvars option is disabled
328 | 	#   * zsh does not unless the PROMPT_SUBST option is set
329 | 	#   * POSIX shells always do
330 | 	#
331 | 	# If the shell would expand the contents of PS1 when drawing
332 | 	# the prompt, a raw ref name must not be included in PS1.
333 | 	# This protects the user from arbitrary code execution via
334 | 	# specially crafted ref names.  For example, a ref named
335 | 	# 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the
336 | 	# shell to execute 'sudo rm -rf /' when the prompt is drawn.
337 | 	#
338 | 	# Instead, the ref name should be placed in a separate global
339 | 	# variable (in the __git_ps1_* namespace to avoid colliding
340 | 	# with the user's environment) and that variable should be
341 | 	# referenced from PS1.  For example:
342 | 	#
343 | 	#     __git_ps1_foo=$(do_something_to_get_ref_name)
344 | 	#     PS1="...stuff...\${__git_ps1_foo}...stuff..."
345 | 	#
346 | 	# If the shell does not expand the contents of PS1, the raw
347 | 	# ref name must be included in PS1.
348 | 	#
349 | 	# The value of this variable is only relevant when in pcmode.
350 | 	#
351 | 	# Assume that the shell follows the POSIX specification and
352 | 	# expands PS1 unless determined otherwise.  (This is more
353 | 	# likely to be correct if the user has a non-bash, non-zsh
354 | 	# shell and safer than the alternative if the assumption is
355 | 	# incorrect.)
356 | 	#
357 | 	local ps1_expanded=yes
358 | 	[ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
359 | 	[ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no
360 | 
361 | 	local repo_info rev_parse_exit_code
362 | 	repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
363 | 		--is-bare-repository --is-inside-work-tree \
364 | 		--short HEAD 2>/dev/null)"
365 | 	rev_parse_exit_code="$?"
366 | 
367 | 	if [ -z "$repo_info" ]; then
368 | 		return $exit
369 | 	fi
370 | 
371 | 	local short_sha
372 | 	if [ "$rev_parse_exit_code" = "0" ]; then
373 | 		short_sha="${repo_info##*$'\n'}"
374 | 		repo_info="${repo_info%$'\n'*}"
375 | 	fi
376 | 	local inside_worktree="${repo_info##*$'\n'}"
377 | 	repo_info="${repo_info%$'\n'*}"
378 | 	local bare_repo="${repo_info##*$'\n'}"
379 | 	repo_info="${repo_info%$'\n'*}"
380 | 	local inside_gitdir="${repo_info##*$'\n'}"
381 | 	local g="${repo_info%$'\n'*}"
382 | 
383 | 	if [ "true" = "$inside_worktree" ] &&
384 | 	   [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
385 | 	   [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
386 | 	   git check-ignore -q .
387 | 	then
388 | 		return $exit
389 | 	fi
390 | 
391 | 	local r=""
392 | 	local b=""
393 | 	local step=""
394 | 	local total=""
395 | 	if [ -d "$g/rebase-merge" ]; then
396 | 		__git_eread "$g/rebase-merge/head-name" b
397 | 		__git_eread "$g/rebase-merge/msgnum" step
398 | 		__git_eread "$g/rebase-merge/end" total
399 | 		if [ -f "$g/rebase-merge/interactive" ]; then
400 | 			r="|REBASE-i"
401 | 		else
402 | 			r="|REBASE-m"
403 | 		fi
404 | 	else
405 | 		if [ -d "$g/rebase-apply" ]; then
406 | 			__git_eread "$g/rebase-apply/next" step
407 | 			__git_eread "$g/rebase-apply/last" total
408 | 			if [ -f "$g/rebase-apply/rebasing" ]; then
409 | 				__git_eread "$g/rebase-apply/head-name" b
410 | 				r="|REBASE"
411 | 			elif [ -f "$g/rebase-apply/applying" ]; then
412 | 				r="|AM"
413 | 			else
414 | 				r="|AM/REBASE"
415 | 			fi
416 | 		elif [ -f "$g/MERGE_HEAD" ]; then
417 | 			r="|MERGING"
418 | 		elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
419 | 			r="|CHERRY-PICKING"
420 | 		elif [ -f "$g/REVERT_HEAD" ]; then
421 | 			r="|REVERTING"
422 | 		elif [ -f "$g/BISECT_LOG" ]; then
423 | 			r="|BISECTING"
424 | 		fi
425 | 
426 | 		if [ -n "$b" ]; then
427 | 			:
428 | 		elif [ -h "$g/HEAD" ]; then
429 | 			# symlink symbolic ref
430 | 			b="$(git symbolic-ref HEAD 2>/dev/null)"
431 | 		else
432 | 			local head=""
433 | 			if ! __git_eread "$g/HEAD" head; then
434 | 				return $exit
435 | 			fi
436 | 			# is it a symbolic ref?
437 | 			b="${head#ref: }"
438 | 			if [ "$head" = "$b" ]; then
439 | 				detached=yes
440 | 				b="$(
441 | 				case "${GIT_PS1_DESCRIBE_STYLE-}" in
442 | 				(contains)
443 | 					git describe --contains HEAD ;;
444 | 				(branch)
445 | 					git describe --contains --all HEAD ;;
446 | 				(describe)
447 | 					git describe HEAD ;;
448 | 				(* | default)
449 | 					git describe --tags --exact-match HEAD ;;
450 | 				esac 2>/dev/null)" ||
451 | 
452 | 				b="$short_sha..."
453 | 				b="($b)"
454 | 			fi
455 | 		fi
456 | 	fi
457 | 
458 | 	if [ -n "$step" ] && [ -n "$total" ]; then
459 | 		r="$r $step/$total"
460 | 	fi
461 | 
462 | 	local w=""
463 | 	local i=""
464 | 	local s=""
465 | 	local u=""
466 | 	local c=""
467 | 	local p=""
468 | 
469 | 	if [ "true" = "$inside_gitdir" ]; then
470 | 		if [ "true" = "$bare_repo" ]; then
471 | 			c="BARE:"
472 | 		else
473 | 			b="GIT_DIR!"
474 | 		fi
475 | 	elif [ "true" = "$inside_worktree" ]; then
476 | 		if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
477 | 		   [ "$(git config --bool bash.showDirtyState)" != "false" ]
478 | 		then
479 | 			git diff --no-ext-diff --quiet --exit-code || w="*"
480 | 			if [ -n "$short_sha" ]; then
481 | 				git diff-index --cached --quiet HEAD -- || i="+"
482 | 			else
483 | 				i="#"
484 | 			fi
485 | 		fi
486 | 		if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
487 | 		   git rev-parse --verify --quiet refs/stash >/dev/null
488 | 		then
489 | 			s="$"
490 | 		fi
491 | 
492 | 		if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
493 | 		   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
494 | 		   git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null
495 | 		then
496 | 			u="%${ZSH_VERSION+%}"
497 | 		fi
498 | 
499 | 		if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
500 | 			__git_ps1_show_upstream
501 | 		fi
502 | 	fi
503 | 
504 | 	local z="${GIT_PS1_STATESEPARATOR-" "}"
505 | 
506 | 	# NO color option unless in PROMPT_COMMAND mode
507 | 	if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
508 | 		__git_ps1_colorize_gitstring
509 | 	fi
510 | 
511 | 	b=${b##refs/heads/}
512 | 	if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
513 | 		__git_ps1_branch_name=$b
514 | 		b="\${__git_ps1_branch_name}"
515 | 	fi
516 | 
517 | 	local f="$w$i$s$u"
518 | 	local gitstring="$c$b${f:+$z$f}$r$p"
519 | 
520 | 	if [ $pcmode = yes ]; then
521 | 		if [ "${__git_printf_supports_v-}" != yes ]; then
522 | 			gitstring=$(printf -- "$printf_format" "$gitstring")
523 | 		else
524 | 			printf -v gitstring -- "$printf_format" "$gitstring"
525 | 		fi
526 | 		PS1="$ps1pc_start$gitstring$ps1pc_end"
527 | 	else
528 | 		printf -- "$printf_format" "$gitstring"
529 | 	fi
530 | 
531 | 	return $exit
532 | }
533 | PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
534 | 


--------------------------------------------------------------------------------
/Lab1-babypython.ipynb:
--------------------------------------------------------------------------------
   1 | {
   2 |  "cells": [
   3 |   {
   4 |    "cell_type": "markdown",
   5 |    "metadata": {},
   6 |    "source": [
   7 |     "# Python and Friends\n",
   8 |     "\n",
   9 |     "This is a very quick run-through of some python syntax"
  10 |    ]
  11 |   },
  12 |   {
  13 |    "cell_type": "code",
  14 |    "execution_count": 1,
  15 |    "metadata": {
  16 |     "collapsed": false
  17 |    },
  18 |    "outputs": [],
  19 |    "source": [
  20 |     "# The %... is an iPython thing, and is not part of the Python language.\n",
  21 |     "# In this case we're just telling the plotting library to draw things on\n",
  22 |     "# the notebook, instead of on a separate window.\n",
  23 |     "%matplotlib inline \n",
  24 |     "#this line above prepares IPython notebook for working with matplotlib\n",
  25 |     "\n",
  26 |     "# See all the \"as ...\" contructs? They're just aliasing the package names.\n",
  27 |     "# That way we can call methods like plt.plot() instead of matplotlib.pyplot.plot().\n",
  28 |     "\n",
  29 |     "import numpy as np # imports a fast numerical programming library\n",
  30 |     "import scipy as sp #imports stats functions, amongst other things\n",
  31 |     "import matplotlib as mpl # this actually imports matplotlib\n",
  32 |     "import matplotlib.cm as cm #allows us easy access to colormaps\n",
  33 |     "import matplotlib.pyplot as plt #sets up plotting under plt\n",
  34 |     "import pandas as pd #lets us handle data as dataframes\n",
  35 |     "#sets up pandas table display\n",
  36 |     "pd.set_option('display.width', 500)\n",
  37 |     "pd.set_option('display.max_columns', 100)\n",
  38 |     "pd.set_option('display.notebook_repr_html', True)\n",
  39 |     "import seaborn as sns #sets up styles and gives us more plotting options"
  40 |    ]
  41 |   },
  42 |   {
  43 |    "cell_type": "markdown",
  44 |    "metadata": {},
  45 |    "source": [
  46 |     "##The Python Language\n",
  47 |     "\n",
  48 |     "Lets talk about using Python as a calculator..."
  49 |    ]
  50 |   },
  51 |   {
  52 |    "cell_type": "code",
  53 |    "execution_count": 2,
  54 |    "metadata": {
  55 |     "collapsed": false
  56 |    },
  57 |    "outputs": [
  58 |     {
  59 |      "data": {
  60 |       "text/plain": [
  61 |        "3"
  62 |       ]
  63 |      },
  64 |      "execution_count": 2,
  65 |      "metadata": {},
  66 |      "output_type": "execute_result"
  67 |     }
  68 |    ],
  69 |    "source": [
  70 |     "1+2"
  71 |    ]
  72 |   },
  73 |   {
  74 |    "cell_type": "markdown",
  75 |    "metadata": {},
  76 |    "source": [
  77 |     "Notice integer division and floating-point error below!"
  78 |    ]
  79 |   },
  80 |   {
  81 |    "cell_type": "code",
  82 |    "execution_count": 3,
  83 |    "metadata": {
  84 |     "collapsed": false
  85 |    },
  86 |    "outputs": [
  87 |     {
  88 |      "data": {
  89 |       "text/plain": [
  90 |        "(0, 0.5, 9.600000000000001)"
  91 |       ]
  92 |      },
  93 |      "execution_count": 3,
  94 |      "metadata": {},
  95 |      "output_type": "execute_result"
  96 |     }
  97 |    ],
  98 |    "source": [
  99 |     "1/2,1.0/2.0,3*3.2"
 100 |    ]
 101 |   },
 102 |   {
 103 |    "cell_type": "markdown",
 104 |    "metadata": {},
 105 |    "source": [
 106 |     "Here is how we can print things. Something on the last line by itself is returned as the output value."
 107 |    ]
 108 |   },
 109 |   {
 110 |    "cell_type": "code",
 111 |    "execution_count": 4,
 112 |    "metadata": {
 113 |     "collapsed": false
 114 |    },
 115 |    "outputs": [
 116 |     {
 117 |      "name": "stdout",
 118 |      "output_type": "stream",
 119 |      "text": [
 120 |       "4.0 \n",
 121 |       "1.66666666667\n"
 122 |      ]
 123 |     },
 124 |     {
 125 |      "data": {
 126 |       "text/plain": [
 127 |        "1"
 128 |       ]
 129 |      },
 130 |      "execution_count": 4,
 131 |      "metadata": {},
 132 |      "output_type": "execute_result"
 133 |     }
 134 |    ],
 135 |    "source": [
 136 |     "print 1+3.0,\"\\n\",5/3.0\n",
 137 |     "5/3"
 138 |    ]
 139 |   },
 140 |   {
 141 |    "cell_type": "markdown",
 142 |    "metadata": {},
 143 |    "source": [
 144 |     "We can obtain the type of a variable, and use boolean comparisons tontest these types."
 145 |    ]
 146 |   },
 147 |   {
 148 |    "cell_type": "code",
 149 |    "execution_count": 5,
 150 |    "metadata": {
 151 |     "collapsed": false
 152 |    },
 153 |    "outputs": [
 154 |     {
 155 |      "name": "stdout",
 156 |      "output_type": "stream",
 157 |      "text": [
 158 |       "0.833333333333\n",
 159 |       "\n"
 160 |      ]
 161 |     }
 162 |    ],
 163 |    "source": [
 164 |     "a=5.0/6.0\n",
 165 |     "print(a)\n",
 166 |     "print type(a)"
 167 |    ]
 168 |   },
 169 |   {
 170 |    "cell_type": "code",
 171 |    "execution_count": 6,
 172 |    "metadata": {
 173 |     "collapsed": false
 174 |    },
 175 |    "outputs": [
 176 |     {
 177 |      "data": {
 178 |       "text/plain": [
 179 |        "True"
 180 |       ]
 181 |      },
 182 |      "execution_count": 6,
 183 |      "metadata": {},
 184 |      "output_type": "execute_result"
 185 |     }
 186 |    ],
 187 |    "source": [
 188 |     "import types\n",
 189 |     "type(a)==types.FloatType"
 190 |    ]
 191 |   },
 192 |   {
 193 |    "cell_type": "code",
 194 |    "execution_count": 7,
 195 |    "metadata": {
 196 |     "collapsed": false
 197 |    },
 198 |    "outputs": [
 199 |     {
 200 |      "data": {
 201 |       "text/plain": [
 202 |        "False"
 203 |       ]
 204 |      },
 205 |      "execution_count": 7,
 206 |      "metadata": {},
 207 |      "output_type": "execute_result"
 208 |     }
 209 |    ],
 210 |    "source": [
 211 |     "type(a)==types.IntType"
 212 |    ]
 213 |   },
 214 |   {
 215 |    "cell_type": "markdown",
 216 |    "metadata": {},
 217 |    "source": [
 218 |     "## Python and Iteration (and files)\n",
 219 |     "\n",
 220 |     "In working with python I always remember: a python is a duck.\n",
 221 |     "\n",
 222 |     "What I mean is, python has a certain way of doing things. For example lets call one of these ways listiness. Listiness works on lists, dictionaries, files, and a general notion of something called an iterator.\n",
 223 |     "\n",
 224 |     "But first, lets introduce the notion of a comprehension. Its a way of constructing a list"
 225 |    ]
 226 |   },
 227 |   {
 228 |    "cell_type": "code",
 229 |    "execution_count": 8,
 230 |    "metadata": {
 231 |     "collapsed": false
 232 |    },
 233 |    "outputs": [
 234 |     {
 235 |      "data": {
 236 |       "text/plain": [
 237 |        "[1, 4, 9, 16, 25]"
 238 |       ]
 239 |      },
 240 |      "execution_count": 8,
 241 |      "metadata": {},
 242 |      "output_type": "execute_result"
 243 |     }
 244 |    ],
 245 |    "source": [
 246 |     "alist=[1,2,3,4,5]\n",
 247 |     "asquaredlist=[i*i for i in alist]\n",
 248 |     "asquaredlist"
 249 |    ]
 250 |   },
 251 |   {
 252 |    "cell_type": "markdown",
 253 |    "metadata": {},
 254 |    "source": [
 255 |     "Python has some nifty functions like `enumerate` and `zip`. The former gives a list of tuples with each tuple of the form `(index, value)`, while the latter takes elements from each list and outs them together into a tuple, thus creating a list of tuples. The first is a duck, but the second isnt."
 256 |    ]
 257 |   },
 258 |   {
 259 |    "cell_type": "code",
 260 |    "execution_count": 9,
 261 |    "metadata": {
 262 |     "collapsed": false
 263 |    },
 264 |    "outputs": [
 265 |     {
 266 |      "data": {
 267 |       "text/plain": [
 268 |        "(, [(1, 1), (2, 4), (3, 9), (4, 16), (5, 25)])"
 269 |       ]
 270 |      },
 271 |      "execution_count": 9,
 272 |      "metadata": {},
 273 |      "output_type": "execute_result"
 274 |     }
 275 |    ],
 276 |    "source": [
 277 |     "enumerate(asquaredlist),zip(alist, asquaredlist)"
 278 |    ]
 279 |   },
 280 |   {
 281 |    "cell_type": "markdown",
 282 |    "metadata": {},
 283 |    "source": [
 284 |     "Someone realized that design flaw and created izip."
 285 |    ]
 286 |   },
 287 |   {
 288 |    "cell_type": "code",
 289 |    "execution_count": 10,
 290 |    "metadata": {
 291 |     "collapsed": false
 292 |    },
 293 |    "outputs": [
 294 |     {
 295 |      "data": {
 296 |       "text/plain": [
 297 |        ""
 298 |       ]
 299 |      },
 300 |      "execution_count": 10,
 301 |      "metadata": {},
 302 |      "output_type": "execute_result"
 303 |     }
 304 |    ],
 305 |    "source": [
 306 |     "from itertools import izip\n",
 307 |     "izip(alist, asquaredlist)"
 308 |    ]
 309 |   },
 310 |   {
 311 |    "cell_type": "code",
 312 |    "execution_count": 11,
 313 |    "metadata": {
 314 |     "collapsed": false
 315 |    },
 316 |    "outputs": [
 317 |     {
 318 |      "name": "stdout",
 319 |      "output_type": "stream",
 320 |      "text": [
 321 |       "\n"
 322 |      ]
 323 |     }
 324 |    ],
 325 |    "source": [
 326 |     "print enumerate(asquaredlist)"
 327 |    ]
 328 |   },
 329 |   {
 330 |    "cell_type": "code",
 331 |    "execution_count": 12,
 332 |    "metadata": {
 333 |     "collapsed": false
 334 |    },
 335 |    "outputs": [
 336 |     {
 337 |      "data": {
 338 |       "text/plain": [
 339 |        "[(0, 1), (1, 4), (2, 9), (3, 16), (4, 25)]"
 340 |       ]
 341 |      },
 342 |      "execution_count": 12,
 343 |      "metadata": {},
 344 |      "output_type": "execute_result"
 345 |     }
 346 |    ],
 347 |    "source": [
 348 |     "[k for k in enumerate(asquaredlist)]"
 349 |    ]
 350 |   },
 351 |   {
 352 |    "cell_type": "markdown",
 353 |    "metadata": {},
 354 |    "source": [
 355 |     "Open files behave like lists too! Here we get each line in the file and find its length, using the comprehension syntax to put these lengths into a big list."
 356 |    ]
 357 |   },
 358 |   {
 359 |    "cell_type": "code",
 360 |    "execution_count": 13,
 361 |    "metadata": {
 362 |     "collapsed": false
 363 |    },
 364 |    "outputs": [
 365 |     {
 366 |      "name": "stdout",
 367 |      "output_type": "stream",
 368 |      "text": [
 369 |       "[9, 27, 2, 24, 2, 2, 2, 2, 22, 2, 28, 60, 29, 28, 27, 22, 22, 24, 25, 18, 24, 11, 21, 20, 22, 32, 10, 28, 31, 12, 22, 27, 2, 51, 32, 2, 67, 13, 2, 18, 2, 2, 2, 8, 2, 50, 2, 49, 2, 6, 14, 2, 7, 45, 2, 6, 21, 2, 7, 11, 2, 6, 5, 2, 7, 41, 2, 6, 53, 2, 7, 48, 25, 2, 6, 27, 2, 7, 23, 2, 6, 19, 39, 46, 2, 7, 48, 2, 32, 2, 6, 25, 2, 6, 27, 2, 7, 22, 2, 6, 30, 24, 2, 7, 24, 22, 2, 9, 2, 6, 18, 2, 6, 6, 25, 2, 6, 17, 2, 6, 45, 2, 6, 47, 2, 6, 22, 2, 6, 36, 42, 48, 38, 45, 37, 42, 2, 6, 32, 2, 6, 18, 41, 42, 31, 2, 6, 20, 41, 2, 6, 20, 51, 51, 43, 30, 2, 6, 51, 2, 23, 2, 6, 48, 2, 6, 43, 2, 6, 47, 2, 6, 49, 2, 6, 23, 2, 6, 23, 2, 6, 50, 42, 40, 54, 2, 6, 17, 2, 6, 22, 2, 6, 42, 2, 15, 2, 6, 33, 2, 6, 46, 42, 22, 2, 6, 41, 38, 19, 2, 6, 26, 2, 6, 25, 36, 40, 45, 42, 15, 2, 6, 48, 47, 2, 6, 48, 44, 48, 2, 6, 49, 47, 43, 43, 41, 50, 43, 46, 50, 30, 2, 6, 13, 47, 42, 44, 45, 53, 53, 53, 36, 50, 45, 39, 43, 35, 50, 39, 49, 36, 47, 41, 39, 48, 42, 39, 46, 45, 41, 50, 44, 2, 6, 37, 47, 49, 45, 2, 6, 41, 43, 41, 51, 45, 50, 43, 47, 43, 48, 42, 39, 45, 38, 46, 2, 19, 2, 53, 42, 14, 40, 44, 14, 42, 40, 11, 39, 41, 53, 19, 53, 2, 6, 40, 2, 6, 27, 2, 6, 12, 2, 6, 12, 2, 6, 12, 2, 15, 2, 38, 35, 38, 39, 2, 6, 44, 2, 6, 42, 38, 44, 48, 43, 42, 40, 41, 37, 2, 6, 38, 46, 44, 45, 49, 51, 48, 42, 2, 6, 45, 45, 47, 42, 42, 39, 45, 47, 44, 2, 6, 45, 44, 2, 11, 2, 2, 2, 52, 2, 63, 35, 2, 7, 47, 46, 52, 38, 47, 42, 41, 47, 47, 43, 42, 52, 45, 42, 45, 46, 47, 39, 46, 44, 46, 47, 40, 44, 49, 47, 47, 41, 43, 44, 46, 46, 43, 42, 45, 41, 48, 34, 49, 2, 16, 47, 2, 7, 41, 2, 35, 2, 45, 47, 41, 54, 45, 43, 42, 46, 34, 2, 7, 16, 44, 49, 37, 42, 50, 49, 2, 7, 51, 2, 6, 47, 37, 41, 41, 2, 7, 45, 45, 41, 2, 6, 54, 2, 7, 46, 2, 6, 44, 2, 8, 43, 50, 38, 40, 53, 37, 2, 6, 26, 2, 8, 11, 39, 2, 6, 45, 44, 38, 41, 40, 41, 49, 48, 45, 44, 47, 2, 7, 52, 47, 48, 53, 37, 43, 38, 46, 43, 40, 41, 44, 40, 43, 48, 46, 43, 48, 48, 48, 40, 45, 43, 35, 46, 41, 40, 38, 39, 43, 45, 2, 8, 46, 49, 2, 6, 41, 2, 7, 38, 41, 43, 45, 45, 48, 52, 41, 2, 26, 2, 6, 45, 38, 39, 49, 42, 40, 43, 53, 49, 50, 41, 46, 46, 47, 45, 38, 47, 55, 45, 47, 46, 48, 54, 49, 37, 44, 43, 46, 43, 40, 49, 2, 43, 2, 6, 24, 2, 6, 28, 34, 2, 6, 48, 2, 6, 54, 47, 12, 2, 6, 17, 2, 6, 47, 47, 2, 6, 37, 2, 6, 37, 40, 39, 45, 38, 47, 2, 6, 47, 2, 6, 43, 44, 2, 6, 41, 2, 6, 50, 47, 42, 41, 39, 2, 6, 17, 2, 6, 28, 2, 6, 39, 2, 6, 40, 39, 2, 6, 41, 2, 6, 10, 2, 6, 32, 2, 6, 21, 2, 6, 35, 41, 38, 21, 2, 6, 29, 2, 6, 42, 40, 43, 51, 35, 43, 49, 45, 55, 39, 46, 38, 49, 45, 50, 43, 32, 2, 6, 21, 2, 6, 46, 2, 6, 26, 2, 6, 17, 45, 39, 43, 43, 43, 30, 2, 6, 20, 2, 6, 44, 43, 24, 2, 6, 45, 30, 2, 15, 17, 2, 6, 17, 2, 7, 17, 2, 6, 18, 2, 7, 29, 2, 6, 28, 2, 6, 41, 2, 6, 29, 2, 6, 45, 2, 6, 14, 2, 6, 17, 2, 6, 30, 2, 6, 18, 2, 6, 27, 2, 6, 32, 2, 6, 39, 2, 6, 53, 2, 15, 17, 2, 6, 19, 2, 6, 30, 2, 6, 40, 19, 2, 6, 24, 30, 2, 6, 20, 2, 6, 40, 50, 43, 44, 42, 41, 42, 46, 46, 17, 2, 6, 26, 2, 6, 39, 2, 44, 2, 46, 52, 53, 53, 2, 9, 2, 2, 2, 40, 2, 30, 2, 7, 40, 40, 40, 27, 2, 6, 20, 2, 7, 45, 40, 40, 45, 41, 10, 2, 6, 17, 2, 7, 19, 43, 46, 41, 46, 42, 44, 49, 41, 37, 46, 44, 48, 42, 55, 42, 39, 47, 45, 46, 45, 50, 32, 44, 45, 39, 38, 39, 46, 44, 44, 41, 42, 41, 48, 2, 6, 45, 48, 40, 45, 47, 47, 29, 2, 7, 17, 45, 2, 19, 2, 38, 38, 2, 6, 47, 45, 56, 2, 38, 2, 38, 51, 41, 43, 52, 49, 45, 48, 42, 45, 46, 52, 40, 46, 40, 49, 45, 37, 44, 44, 45, 43, 42, 44, 2, 7, 42, 2, 6, 47, 2, 7, 38, 26, 2, 6, 27, 44, 2, 7, 11, 2, 9, 2, 6, 42, 2, 6, 52, 2, 6, 24, 39, 45, 53, 37, 46, 43, 45, 44, 2, 6, 45, 25, 2, 6, 47, 41, 47, 2, 6, 46, 2, 6, 47, 49, 54, 48, 45, 2, 6, 42, 24, 2, 6, 44, 2, 6, 52, 42, 2, 6, 45, 45, 48, 48, 45, 44, 47, 40, 44, 43, 38, 41, 50, 47, 39, 44, 43, 51, 40, 48, 42, 2, 6, 24, 2, 11, 2, 2, 2, 25, 2, 41, 2, 6, 42, 2, 6, 35, 2, 6, 16, 2, 6, 29, 2, 6, 19, 2, 6, 52, 43, 2, 57, 2, 31, 2, 6, 50, 52, 49, 43, 28, 2, 6, 17, 2, 6, 18, 43, 41, 50, 39, 47, 50, 42, 52, 39, 37, 48, 50, 42, 39, 50, 46, 50, 43, 45, 48, 35, 46, 46, 42, 21, 2, 6, 26, 2, 16, 2, 6, 44, 46, 55, 38, 42, 51, 41, 41, 44, 48, 39, 41, 44, 49, 43, 46, 38, 48, 49, 2, 25, 2, 6, 36, 37, 15, 2, 6, 33, 40, 24, 2, 6, 18, 2, 6, 43, 2, 6, 18, 2, 6, 31, 38, 42, 35, 43, 2, 6, 49, 40, 42, 43, 49, 41, 42, 39, 38, 28, 2, 6, 22, 26, 2, 6, 28, 2, 6, 22, 2, 6, 29, 2, 6, 20, 42, 40, 2, 18, 2, 45, 2, 28, 2, 53, 40, 2, 28, 2, 6, 38, 2, 6, 46, 2, 6, 44, 2, 6, 46, 2, 6, 24, 2, 6, 24, 2, 11, 2, 2, 2, 44, 2, 27, 2, 6, 55, 2, 8, 10, 2, 6, 9, 2, 8, 25, 44, 24, 2, 6, 19, 2, 8, 43, 25, 2, 6, 28, 2, 8, 47, 2, 6, 7, 2, 8, 27, 46, 44, 48, 49, 41, 43, 51, 58, 41, 42, 41, 37, 53, 43, 2, 6, 8, 2, 8, 45, 2, 6, 9, 2, 8, 41, 45, 2, 6, 49, 40, 26, 2, 8, 18, 47, 42, 51, 46, 49, 36, 44, 46, 22, 2, 6, 22, 13, 2, 8, 45, 54, 45, 41, 45, 41, 41, 45, 43, 45, 19, 40, 48, 44, 37, 22, 45, 47, 36, 38, 41, 40, 39, 40, 48, 43, 41, 43, 47, 41, 48, 21, 44, 50, 41, 37, 43, 39, 42, 43, 37, 39, 40, 47, 48, 46, 49, 42, 41, 36, 2, 9, 2, 6, 47, 51, 43, 41, 48, 42, 34, 42, 51, 42, 42, 41, 46, 26, 46, 39, 50, 47, 2, 12, 2, 43, 36, 17, 2, 6, 31, 2, 6, 26, 2, 6, 30, 2, 6, 11, 2, 6, 34, 2, 6, 39, 2, 32, 2, 6, 26, 2, 6, 21, 2, 6, 15, 2, 6, 24, 2, 6, 23, 2, 6, 28, 2, 6, 17, 2, 6, 55, 23, 2, 15, 25, 2, 6, 49, 27, 2, 6, 52, 18, 2, 6, 35, 43, 45, 54, 41, 43, 25, 2, 6, 49, 2, 6, 38, 23, 2, 6, 30, 2, 6, 47, 52, 46, 45, 49, 45, 27, 2, 6, 30, 2, 6, 47, 2, 15, 23, 2, 6, 19, 2, 6, 11, 17, 2, 6, 27, 2, 6, 16, 2, 6, 34, 2, 6, 32, 2, 8, 19, 2, 6, 58, 52, 19, 2, 6, 28, 2, 6, 44, 20, 2, 8, 19, 2, 6, 47, 25, 41, 45, 20, 2, 8, 19, 2, 6, 55, 51, 2, 6, 48, 2, 6, 46, 53, 40, 13, 44, 44, 45, 35, 49, 48, 44, 60, 62, 39, 48, 48, 8, 2, 8, 19, 2, 6, 47, 42, 37, 51, 53, 46, 44, 41, 31, 2, 11, 2, 2, 2, 9, 2, 38, 2, 32, 2, 6, 48, 2, 6, 18, 2, 6, 48, 39, 19, 2, 6, 27, 2, 6, 50, 46, 52, 45, 46, 48, 45, 53, 46, 47, 2, 6, 25, 2, 6, 50, 40, 43, 48, 42, 46, 40, 23, 2, 6, 21, 2, 6, 50, 31, 2, 6, 36, 2, 6, 48, 42, 34, 59, 43, 41, 36, 21, 2, 6, 22, 2, 6, 31, 2, 6, 14, 20, 2, 6, 30, 41, 43, 51, 11, 46, 44, 45, 41, 50, 41, 21, 2, 6, 21, 2, 6, 67, 64, 2, 6, 56, 13, 2, 6, 44, 50, 38, 56, 49, 45, 43, 39, 14, 50, 40, 42, 38, 38, 46, 2, 6, 18, 2, 6, 32, 2, 6, 15, 2, 6, 38, 2, 6, 19, 2, 6, 28, 2, 6, 16, 2, 6, 11, 2, 18, 2, 18, 2, 38, 2, 6, 43, 2, 6, 32, 2, 6, 41, 46, 45, 42, 51, 39, 38, 43, 2, 6, 19, 2, 6, 25, 25, 2, 6, 15, 2, 6, 44, 44, 45, 37, 41, 41, 48, 42, 40, 46, 45, 45, 46, 43, 2, 6, 44, 35, 40, 47, 36, 46, 50, 2, 6, 44, 36, 19, 2, 6, 25, 47, 51, 51, 34, 42, 38, 46, 57, 45, 2, 11, 2, 2, 2, 33, 2, 58, 2, 7, 45, 44, 41, 45, 43, 43, 43, 54, 44, 39, 51, 51, 48, 40, 45, 41, 50, 39, 2, 8, 45, 44, 48, 41, 40, 40, 43, 31, 2, 6, 21, 47, 44, 19, 2, 7, 15, 47, 41, 18, 2, 7, 46, 2, 8, 46, 38, 44, 44, 2, 7, 45, 30, 2, 8, 11, 2, 58, 2, 19, 2, 6, 44, 24, 2, 7, 47, 2, 6, 45, 36, 41, 45, 39, 43, 36, 2, 7, 43, 2, 6, 43, 49, 2, 7, 46, 2, 18, 2, 44, 50, 2, 8, 40, 48, 2, 7, 26, 2, 49, 2, 27, 47, 2, 7, 44, 41, 44, 41, 41, 50, 42, 47, 43, 44, 39, 49, 40, 48, 46, 42, 41, 18, 45, 45, 41, 26, 2, 7, 19, 45, 39, 50, 49, 20, 2, 35, 2, 6, 32, 38, 39, 51, 49, 46, 51, 42, 44, 43, 18, 2, 8, 29, 2, 6, 37, 49, 44, 41, 44, 44, 42, 43, 42, 10, 48, 39, 46, 10, 60, 13, 61, 35, 10, 44, 2, 8, 31, 2, 6, 46, 10, 35, 36, 30, 30, 63, 67, 12, 67, 15, 49, 39, 48, 24, 2, 7, 18, 20, 2, 6, 26, 2, 7, 38, 2, 6, 50, 46, 42, 47, 44, 41, 45, 45, 49, 43, 46, 50, 47, 41, 47, 44, 40, 44, 49, 40, 22, 2, 7, 25, 2, 8, 25, 2, 6, 52, 40, 27, 2, 7, 18, 2, 6, 44, 36, 39, 47, 20, 2, 7, 28, 2, 6, 48, 20, 2, 8, 20, 2, 6, 47, 36, 41, 43, 37, 30, 2, 7, 17, 2, 8, 53, 2, 6, 35, 46, 2, 39, 2, 26, 2, 31, 2, 6, 20, 2, 6, 26, 2, 6, 38, 2, 6, 17, 2, 6, 40, 2, 6, 18, 2, 6, 61, 29, 2, 6, 28, 2, 6, 65, 32, 2, 6, 18, 2, 6, 64, 52, 2, 6, 67, 64, 65, 65, 16, 2, 6, 22, 2, 6, 30, 2, 6, 14, 2, 6, 44, 2, 6, 63, 61, 61, 65, 67, 62, 64, 2, 6, 64, 40, 2, 6, 16, 2, 6, 65, 64, 64, 67, 67, 18, 2, 6, 57, 67, 7, 2, 6, 25, 2, 6, 26, 2, 39, 2, 6, 46, 2, 6, 35, 2, 18, 2, 7, 19, 2, 6, 20, 2, 6, 61, 41, 2, 6, 43, 2, 7, 38, 46, 2, 6, 28, 2, 6, 19, 2, 6, 56, 10, 2, 7, 25, 2, 6, 56, 28, 2, 6, 51, 2, 6, 58, 62, 64, 9, 2, 7, 18, 2, 6, 21, 2, 6, 24, 2, 6, 60, 43, 2, 6, 27, 2, 6, 62, 56, 2, 6, 65, 7, 2, 6, 61, 61, 2, 7, 63, 48, 2, 6, 33, 2, 6, 64, 30, 2, 6, 64, 64, 23, 2, 17, 22, 2, 6, 57, 62, 65, 23, 2, 6, 43, 2, 6, 62, 66, 58, 64, 2, 7, 30, 2, 6, 59, 67, 65, 20, 2, 6, 23, 2, 6, 63, 59, 64, 66, 38, 2, 6, 34, 2, 6, 65, 10, 2, 7, 28, 2, 6, 60, 60, 66, 64, 64, 67, 66, 64, 65, 60, 62, 64, 67, 66, 53, 2, 6, 50, 2, 6, 60, 2, 6, 59, 65, 62, 2, 6, 61, 67, 65, 63, 63, 63, 7, 2, 6, 56, 25, 2, 6, 54, 46, 2, 6, 57, 13, 2, 6, 61, 29, 2, 6, 27, 2, 6, 35, 2, 6, 62, 66, 65, 67, 65, 27, 2, 6, 58, 63, 57, 67, 66, 31, 2, 6, 64, 62, 66, 32, 2, 6, 16, 2, 7, 50, 2, 6, 28, 2, 6, 55, 2, 6, 62, 65, 67, 67, 31, 2, 32, 2, 7, 24, 2, 6, 63, 64, 63, 60, 64, 31, 2, 7, 24, 2, 6, 61, 29, 2, 19, 2, 6, 30, 2, 6, 67, 66, 2, 6, 64, 23, 2, 6, 67, 53, 2, 6, 35, 2, 6, 64, 9, 2, 6, 38, 2, 6, 13, 2, 6, 19, 2, 6, 36, 2, 6, 59, 59, 66, 64, 67, 15, 2, 6, 58, 2, 6, 32, 2, 6, 7, 37, 38, 2, 2, 6, 32, 2, 6, 38, 2, 6, 60, 20, 2, 6, 24, 2, 6, 30, 2, 6, 7, 26, 21, 45, 65, 28, 2, 31, 2, 64, 62, 60, 61, 63, 62, 67, 60, 64, 51, 2, 9, 23, 2, 6, 63, 65, 66, 67, 67, 64, 64, 61, 62, 67, 67, 64, 61, 2, 49, 2, 43, 2, 46, 49, 48, 53, 44, 44, 53, 50, 45, 54, 44, 51, 32, 2, 18, 2, 6, 60, 13, 2, 9, 23, 53, 48, 43, 51, 50, 53, 48, 49, 52, 42, 51, 44, 48, 17, 45, 52, 49, 48, 52, 44, 44, 47, 51, 26, 52, 43, 53, 53, 29, 2, 6, 19, 2, 6, 64, 65, 12, 2, 9, 49, 2, 6, 21, 2, 6, 38, 2, 9, 53, 46, 49, 45, 49, 53, 59, 49, 46, 51, 50, 49, 54, 29, 2, 6, 64, 27, 2, 6, 62, 62, 67, 65, 51, 2, 6, 53, 2, 6, 53, 64, 65, 28, 2, 6, 13, 2, 6, 51, 2, 55, 2, 60, 11, 2, 9, 14, 2, 6, 60, 66, 29, 2, 9, 14, 2, 6, 58, 2, 22, 2, 61, 37, 2, 6, 15, 2, 40, 2, 6, 24, 17, 41, 44, 42, 44, 45, 45, 48, 49, 13, 40, 48, 43, 50, 48, 42, 43, 38, 8, 40, 45, 41, 40, 42, 46, 46, 55, 48, 46, 40, 40, 43, 49, 56, 15, 44, 44, 44, 48, 38, 13, 49, 43, 39, 43, 42, 50, 53, 45, 44, 47, 47, 44, 46, 41, 43, 41, 48, 48, 2, 9, 2, 2, 2, 2, 10, 2, 32, 2, 57, 16, 2, 7, 43, 45, 42, 38, 2, 6, 46, 48, 2, 7, 43, 41, 47, 20, 2, 8, 26, 2, 6, 24, 2, 7, 43, 2, 6, 43, 25, 2, 8, 19, 17, 2, 6, 44, 50, 41, 42, 42, 32, 2, 6, 17, 47, 29, 2, 7, 48, 28, 42, 45, 2, 6, 20, 2, 40, 2, 7, 31, 45, 42, 18, 43, 48, 42, 38, 42, 27, 2, 8, 21, 39, 44, 52, 41, 23, 2, 6, 23, 2, 15, 2, 6, 51, 61, 42, 50, 52, 35, 20, 2, 7, 28, 55, 51, 45, 42, 17, 2, 6, 45, 2, 29, 2, 17, 2, 6, 47, 43, 45, 44, 49, 39, 48, 45, 45, 53, 50, 45, 41, 38, 50, 51, 46, 41, 43, 40, 51, 40, 48, 44, 42, 45, 41, 46, 39, 49, 43, 45, 45, 42, 28, 2, 6, 15, 43, 2, 6, 39, 2, 6, 39, 40, 31, 2, 6, 12, 25, 2, 6, 48, 49, 51, 41, 47, 17, 2, 6, 25, 2, 6, 10, 2, 6, 15, 2, 6, 27, 2, 6, 62, 27, 2, 6, 64, 2, 6, 58, 65, 66, 55, 2, 6, 42, 2, 6, 55, 64, 6, 2, 6, 26, 2, 6, 57, 65, 67, 66, 63, 67, 66, 60, 9, 2, 6, 19, 2, 6, 59, 39, 2, 6, 33, 2, 6, 65, 66, 64, 63, 63, 11, 2, 6, 33, 2, 6, 59, 67, 66, 67, 63, 66, 29, 2, 9, 2, 6, 42, 59, 44, 45, 52, 43, 42, 47, 50, 48, 37, 48, 2, 31, 2, 7, 44, 52, 53, 42, 43, 44, 31, 51, 42, 42, 36, 45, 48, 47, 2, 6, 40, 42, 48, 45, 46, 41, 44, 47, 47, 47, 43, 31, 2, 7, 17, 46, 2, 11, 2, 2, 2, 33, 2, 37, 2, 6, 58, 64, 65, 60, 62, 52, 65, 67, 67, 65, 67, 52, 2, 11, 24, 2, 6, 62, 66, 63, 66, 63, 64, 64, 66, 60, 62, 65, 65, 59, 64, 60, 64, 25, 2, 11, 58, 2, 6, 62, 63, 63, 64, 65, 64, 17, 2, 19, 2, 50, 2, 58, 2, 6, 40, 2, 6, 29, 2, 18, 2, 35, 2, 16, 19, 2, 25, 2, 6, 20, 2, 18, 2, 6, 36, 2, 6, 38, 39, 2, 6, 20, 2, 6, 30, 44, 45, 60, 46, 43, 50, 48, 44, 50, 49, 42, 52, 49, 47, 49, 50, 47, 46, 43, 46, 47, 47, 40, 43, 39, 41, 33, 44, 41, 45, 28, 2, 6, 16, 52, 44, 2, 6, 46, 18, 2, 66, 41, 2, 7, 30, 2, 6, 62, 45, 2, 7, 62, 7, 2, 6, 67, 21, 2, 6, 54, 2, 6, 21, 2, 6, 64, 12, 2, 6, 65, 20, 2, 6, 44, 2, 8, 41, 2, 6, 48, 2, 6, 41, 2, 6, 32, 33, 2, 6, 14, 2, 6, 32, 2, 6, 14, 2, 6, 39, 2, 6, 27, 2, 6, 51, 2, 6, 19, 2, 6, 10, 2, 6, 25, 2, 6, 9, 2, 6, 14, 2, 6, 60, 65, 22, 2, 6, 38, 2, 6, 62, 66, 66, 67, 62, 57, 2, 41, 2, 62, 60, 59, 57, 63, 66, 66, 61, 64, 67, 43, 2, 11, 2, 6, 27, 2, 6, 53, 2, 6, 52, 2, 19, 2, 6, 64, 19, 2, 6, 39, 2, 6, 61, 50, 2, 6, 53, 2, 6, 33, 36, 35, 2, 6, 44, 2, 6, 22, 2, 6, 18, 2, 29, 2, 10, 49, 47, 44, 50, 49, 39, 2, 11, 39, 44, 42, 47, 46, 43, 43, 36, 49, 41, 52, 56, 2, 10, 50, 48, 48, 42, 27, 2, 11, 23, 47, 38, 47, 2, 6, 30, 2, 11, 41, 48, 38, 39, 2, 10, 44, 40, 37, 38, 51, 40, 36, 45, 42, 44, 37, 46, 48, 47, 49, 54, 43, 50, 51, 45, 41, 46, 43, 33, 38, 40, 40, 52, 43, 51, 2, 11, 46, 46, 40, 42, 43, 46, 47, 35, 2, 6, 43, 2, 10, 49, 48, 29, 11, 2, 11, 23, 44, 2, 9, 2, 6, 32, 2, 8, 39, 2, 6, 30, 2, 7, 56, 2, 6, 61, 8, 2, 7, 28, 2, 6, 58, 63, 65, 61, 66, 14, 2, 19, 2, 43, 2, 6, 33, 2, 6, 61, 23, 2, 6, 38, 2, 6, 51, 2, 6, 26, 2, 6, 62, 64, 22, 2, 6, 58, 46, 49, 52, 37, 38, 2, 45, 2, 6, 64, 62, 66, 2, 6, 17, 2, 6, 33, 2, 8, 20, 2, 6, 21, 2, 7, 28, 2, 6, 25, 2, 38, 2, 6, 40, 30, 48, 32, 66, 62, 60, 2, 6, 15, 2, 6, 22, 38, 32, 41, 28, 2, 6, 24, 2, 6, 59, 24, 2, 6, 21, 2, 6, 35, 2, 6, 27, 2, 6, 51, 41, 45, 19, 2, 39, 2, 7, 45, 2, 6, 23, 2, 7, 17, 2, 6, 23, 2, 7, 48, 2, 6, 18, 2, 7, 34, 2, 6, 63, 62, 34, 2, 7, 61, 31, 2, 6, 29, 2, 7, 61, 22, 2, 6, 18, 2, 7, 61, 65, 62, 34, 2, 6, 16, 2, 7, 16, 2, 6, 64, 65, 65, 8, 2, 6, 57, 27, 2, 6, 65, 50, 2, 6, 64, 2, 6, 60, 24, 2, 6, 32, 2, 6, 51, 2, 6, 64, 63, 14, 2, 6, 26, 2, 6, 62, 33, 2, 6, 64, 8, 2, 41, 2, 67, 66, 14, 2, 7, 63, 2, 6, 62, 2, 7, 20, 2, 6, 13, 2, 7, 23, 2, 6, 19, 2, 7, 34, 2, 6, 56, 63, 63, 2, 7, 59, 21, 2, 6, 61, 64, 63, 64, 63, 65, 65, 26, 2, 19, 2, 21, 2, 6, 57, 2, 6, 60, 2, 6, 44, 2, 6, 31, 2, 6, 29, 2, 6, 18, 2, 6, 20, 2, 6, 63, 41, 2, 6, 16, 2, 9, 2, 6, 27, 2, 18, 2, 22, 2, 41, 2, 43, 53, 55, 40, 51, 44, 41, 33, 44, 45, 39, 45, 2, 9, 2, 2, 2, 34, 2, 46, 2, 7, 44, 50, 44, 41, 40, 39, 22, 2, 7, 28, 36, 37, 39, 2, 6, 40, 47, 45, 45, 41, 43, 46, 43, 49, 50, 42, 42, 46, 2, 7, 45, 41, 33, 2, 15, 19, 2, 25, 2, 19, 2, 6, 45, 37, 56, 43, 50, 50, 50, 39, 27, 2, 7, 23, 2, 18, 2, 45, 43, 38, 41, 45, 43, 45, 44, 50, 47, 48, 40, 48, 40, 44, 47, 49, 44, 48, 44, 45, 41, 45, 43, 42, 47, 49, 47, 45, 43, 41, 43, 44, 45, 57, 41, 18, 2, 23, 2, 17, 2, 6, 43, 47, 47, 42, 44, 12, 42, 43, 51, 50, 48, 48, 41, 46, 5, 46, 42, 43, 40, 41, 51, 46, 44, 43, 2, 9, 2, 32, 2, 7, 44, 44, 2, 9, 2, 2, 2, 39, 2, 29, 2, 6, 50, 55, 53, 47, 30, 2, 6, 35, 2, 8, 19, 44, 2, 35, 2, 17, 2, 6, 33, 2, 8, 45, 2, 6, 43, 2, 8, 45, 2, 6, 44, 2, 8, 23, 2, 6, 24, 2, 8, 21, 2, 6, 26, 51, 49, 2, 8, 50, 2, 6, 52, 38, 43, 2, 8, 47, 17, 2, 6, 39, 2, 6, 26, 25, 2, 35, 2, 6, 26, 2, 19, 2, 8, 28, 2, 6, 34, 2, 25, 2, 8, 41, 2, 6, 45, 44, 2, 8, 17, 2, 6, 28, 48, 16, 47, 47, 52, 46, 36, 40, 45, 2, 8, 51, 30, 2, 6, 13, 44, 44, 45, 47, 43, 40, 41, 47, 39, 44, 29, 2, 8, 18, 48, 2, 6, 45, 46, 43, 46, 44, 35, 39, 35, 43, 39, 52, 44, 48, 48, 45, 42, 48, 48, 54, 53, 42, 44, 41, 49, 46, 46, 48, 40, 20, 47, 43, 40, 45, 46, 43, 26, 2, 8, 26, 43, 46, 32, 2, 6, 18, 39, 48, 23, 2, 8, 25, 46, 24, 2, 6, 27, 46, 42, 40, 45, 27, 2, 8, 10, 2, 6, 33, 2, 16, 2, 44, 56, 2, 8, 17, 2, 6, 42, 46, 45, 9, 2, 8, 32, 44, 42, 46, 46, 23, 2, 6, 27, 2, 8, 26, 39, 48, 46, 45, 45, 42, 42, 46, 2, 6, 46, 52, 48, 43, 42, 51, 2, 8, 28, 2, 6, 27, 2, 8, 40, 2, 6, 27, 2, 8, 28, 2, 6, 47, 38, 50, 2, 15, 2, 8, 41, 32, 21, 2, 6, 10, 49, 49, 44, 46, 47, 46, 48, 47, 44, 45, 44, 45, 49, 41, 40, 45, 2, 8, 46, 2, 6, 38, 41, 45, 38, 46, 41, 42, 37, 41, 40, 45, 48, 45, 47, 41, 47, 25, 45, 43, 44, 41, 47, 35, 46, 27, 2, 8, 18, 2, 6, 43, 44, 49, 43, 51, 40, 39, 49, 48, 42, 46, 38, 38, 46, 41, 31, 2, 8, 46, 47, 28, 2, 6, 35, 2, 8, 8, 37, 2, 6, 53, 46, 47, 41, 40, 49, 45, 48, 46, 32, 46, 46, 49, 42, 46, 21, 2, 52, 2, 2, 2, 9, 2, 32, 2, 52, 2, 7, 54, 50, 20, 2, 8, 41, 2, 48, 2, 46, 2, 7, 34, 2, 8, 44, 43, 42, 45, 42, 26, 2, 7, 15, 44, 40, 39, 47, 41, 54, 46, 44, 40, 40, 45, 2, 8, 40, 43, 33, 47, 2, 7, 24, 45, 48, 40, 49, 2, 42, 2, 50, 40, 51, 49, 45, 2, 40, 2, 51, 43, 47, 42, 38, 51, 43, 40, 2, 11, 2, 39, 2, 17, 2, 6, 16, 2, 16, 32, 2, 6, 53, 2, 39, 2, 6, 50, 2, 6, 44, 2, 6, 49, 28, 2, 6, 20, 2, 6, 15, 2, 6, 64, 67, 12, 2, 6, 36, 2, 6, 61, 64, 64, 66, 65, 8, 2, 6, 32, 2, 6, 60, 2, 6, 63, 11, 2, 6, 63, 24, 2, 7, 19, 2, 6, 55, 2, 11, 2, 2, 2, 40, 2, 24, 2, 7, 47, 47, 44, 41, 49, 55, 53, 40, 44, 38, 16, 2, 22, 2, 30, 2, 6, 43, 25, 2, 7, 18, 2, 6, 51, 2, 7, 22, 2, 6, 37, 2, 34, 2, 7, 32, 2, 6, 12, 2, 7, 19, 2, 6, 53, 65, 65, 66, 64, 10, 2, 7, 13, 2, 6, 63, 41, 2, 7, 30, 2, 6, 62, 23, 2, 7, 20, 2, 6, 64, 66, 65, 28, 2, 7, 42, 2, 6, 29, 2, 22, 2, 7, 49, 41, 54, 50, 42, 45, 14, 2, 6, 14, 2, 7, 13, 2, 6, 7, 2, 7, 41, 2, 6, 59, 24, 2, 7, 28, 2, 6, 63, 51, 2, 9, 2, 7, 50, 45, 41, 54, 2, 40, 2, 51, 48, 43, 42, 47, 47, 38, 46, 43, 47, 44, 2, 9, 2, 2, 2, 31, 2, 42, 2, 6, 45, 43, 43, 44, 42, 39, 22, 2, 7, 23, 2, 6, 15, 2, 31, 2, 48, 2, 6, 35, 2, 7, 26, 2, 6, 32, 2, 7, 30, 2, 6, 25, 2, 7, 39, 2, 6, 42, 23, 2, 7, 39, 40, 41, 48, 41, 42, 2, 6, 44, 2, 7, 32, 2, 6, 47, 45, 50, 48, 45, 2, 7, 22, 2, 9, 2, 6, 32, 2, 6, 48, 2, 26, 2, 40, 42, 42, 45, 49, 39, 36, 42, 42, 43, 54, 45, 45, 54, 47, 45, 38, 44, 38, 36, 46, 44, 40, 40, 48, 46, 40, 46, 43, 40, 48, 43, 40, 46, 45, 2, 9, 2, 2, 2, 42, 2, 28, 2, 8, 28, 2, 7, 38, 32, 2, 8, 22, 2, 7, 47, 61, 53, 51, 38, 44, 51, 57, 53, 42, 53, 46, 2, 8, 18, 2, 17, 2, 43, 46, 39, 42, 2, 34, 2, 6, 44, 2, 8, 19, 2, 15, 37, 24, 33, 28, 2, 8, 43, 2, 6, 31, 10, 31, 27, 36, 28, 2, 8, 20, 2, 6, 17, 10, 43, 2, 15, 2, 8, 27, 2, 6, 10, 37, 37, 30, 2, 7, 26, 2, 6, 62, 67, 13, 2, 7, 26, 2, 6, 67, 25, 10, 39, 34, 33, 28, 2, 44, 35, 37, 27, 2, 7, 17, 2, 6, 53, 10, 33, 32, 43, 34, 2, 38, 30, 40, 40, 2, 7, 30, 2, 6, 59, 66, 63, 66, 33, 2, 9, 2, 7, 52, 2, 17, 2, 49, 52, 48, 45, 49, 45, 58, 56, 45, 45, 51, 44, 44, 47, 41, 48, 40, 42, 43, 43, 29, 2, 19, 2, 8, 28, 2, 7, 49, 2, 22, 2, 21, 2, 7, 25, 37, 46, 40, 51, 42, 37, 40, 46, 52, 40, 2, 8, 45, 44, 2, 19, 2, 7, 22, 2, 42, 2, 7, 51, 2, 8, 20, 2, 7, 28, 2, 8, 19, 2, 33, 2, 7, 49, 20, 2, 8, 23, 2, 7, 54, 47, 47, 20, 2, 7, 29, 43, 47, 42, 45, 45, 54, 13, 2, 7, 21, 2, 7, 7, 2, 8, 17, 2, 7, 26, 2, 7, 45, 51, 47, 45, 45, 44, 31, 2, 7, 21, 2, 7, 29, 46, 32, 2, 7, 15, 37, 56, 54, 19, 2, 7, 23, 2, 7, 26, 2, 7, 49, 44, 28, 2, 7, 20, 41, 45, 39, 43, 26, 2, 8, 27, 2, 7, 30, 2, 58, 11, 2, 51, 46, 49, 46, 42, 46, 43, 46, 43, 27, 2, 6, 10, 40, 35, 43, 2, 25, 2, 7, 50, 25, 2, 6, 59, 67, 20, 2, 7, 34, 2, 6, 55, 54, 2, 7, 58, 2, 6, 63, 58, 67, 67, 49, 10, 43, 2, 7, 47, 40, 2, 6, 10, 32, 32, 26, 27, 30, 2, 36, 29, 30, 29, 31, 2, 57, 2, 9, 2, 7, 25, 2, 7, 42, 37, 51, 50, 36, 49, 49, 37, 45, 44, 25, 2, 7, 17, 43, 49, 41, 50, 33, 2, 7, 15, 50, 24, 2, 11, 2, 2, 2, 39, 2, 32, 2, 6, 41, 2, 10, 51, 2, 6, 19, 2, 17, 2, 43, 47, 2, 18, 2, 11, 21, 2, 6, 25, 2, 9, 59, 67, 50, 2, 6, 52, 60, 63, 63, 66, 63, 67, 67, 66, 66, 66, 65, 65, 58, 44, 2, 51, 47, 36, 2, 11, 2, 2, 2, 40, 2, 27, 2, 7, 47, 47, 46, 44, 18, 2, 7, 31, 44, 39, 45, 29, 2, 7, 29, 49, 53, 46, 47, 43, 48, 43, 39, 48, 49, 52, 49, 43, 38, 33, 2, 7, 36, 41, 44, 42, 49, 2, 7, 53, 44, 49, 52, 43, 48, 2, 22, 2, 21, 2, 7, 32, 42, 2, 7, 32, 2, 7, 45, 50, 27, 2, 7, 31, 11, 2, 19, 2, 65, 63, 63, 64, 2, 52, 41, 2, 7, 20, 2, 7, 38, 44, 20, 2, 7, 45, 40, 46, 21, 2, 7, 25, 42, 26, 2, 7, 14, 41, 2, 7, 45, 46, 43, 36, 47, 42, 49, 23, 2, 7, 27, 38, 28, 2, 7, 17, 49, 45, 47, 43, 42, 27, 2, 7, 29, 2, 7, 36, 44, 45, 44, 52, 37, 51, 50, 45, 47, 43, 51, 42, 28, 2, 7, 17, 2, 7, 11, 2, 7, 23, 2, 7, 16, 2, 7, 42, 28, 2, 7, 28, 37, 39, 38, 46, 54, 47, 46, 37, 43, 44, 21, 2, 7, 28, 2, 7, 39, 43, 25, 2, 7, 19, 2, 7, 48, 40, 39, 42, 43, 45, 42, 37, 45, 55, 40, 49, 52, 56, 45, 44, 21, 2, 7, 34, 2, 7, 46, 51, 51, 47, 49, 38, 52, 44, 46, 47, 44, 46, 30, 2, 7, 14, 44, 38, 40, 44, 45, 47, 51, 52, 18, 2, 7, 30, 47, 47, 54, 51, 47, 49, 47, 9, 44, 48, 53, 47, 44, 29, 2, 16, 2, 23, 2, 8, 41, 55, 2, 7, 20, 2, 8, 41, 50, 44, 53, 45, 53, 48, 46, 42, 53, 45, 48, 39, 38, 45, 49, 47, 17, 2, 7, 28, 2, 8, 19, 2, 7, 44, 42, 43, 50, 41, 49, 31, 2, 9, 2, 7, 25, 40, 43, 25, 2, 11, 2, 2, 2, 8, 2, 24, 2, 38, 2, 10, 59, 26, 2, 10, 64, 57, 2, 10, 65, 2, 10, 21, 2, 10, 60, 66, 63, 39, 2, 10, 38, 2, 10, 59, 66, 66, 64, 56, 2, 10, 18, 2, 10, 39, 2, 10, 53, 67, 2, 10, 59, 67, 62, 67, 28, 2, 10, 21, 2, 10, 39, 2, 10, 19, 2, 10, 62, 65, 63, 29, 2, 10, 8, 2, 10, 60, 31, 2, 10, 64, 2, 10, 60, 63, 61, 67, 2, 10, 65, 2, 10, 31, 2, 10, 24, 2, 10, 7, 2, 10, 22, 2, 44, 2, 10, 60, 61, 62, 61, 9, 2, 22, 2, 19, 2, 40, 35, 49, 43, 2, 6, 62, 15, 2, 6, 52, 2, 6, 63, 8, 2, 10, 10, 38, 36, 39, 35, 2, 22, 2, 6, 61, 64, 63, 64, 15, 2, 6, 20, 2, 6, 61, 67, 57, 20, 2, 6, 14, 2, 6, 61, 65, 64, 62, 7, 2, 10, 10, 36, 33, 36, 32, 2, 28, 2, 6, 61, 66, 65, 65, 65, 64, 65, 65, 64, 65, 65, 66, 11, 2, 6, 26, 2, 6, 39, 2, 6, 37, 2, 6, 63, 54, 2, 10, 12, 10, 36, 32, 2, 6, 50, 2, 10, 67, 36, 2, 6, 62, 52, 2, 10, 59, 2, 6, 32, 2, 10, 18, 2, 6, 18, 2, 10, 19, 2, 6, 27, 2, 10, 60, 2, 6, 58, 62, 64, 66, 57, 2, 10, 60, 39, 2, 6, 25, 2, 10, 60, 64, 15, 2, 6, 42, 2, 10, 59, 47, 2, 6, 6, 2, 10, 66, 2, 6, 18, 2, 10, 27, 2, 6, 16, 2, 10, 35, 2, 6, 19, 2, 10, 61, 15, 2, 6, 50, 2, 10, 60, 66, 64, 16, 2, 6, 27, 2, 10, 61, 67, 67, 38, 2, 6, 15, 2, 10, 61, 2, 6, 18, 2, 10, 60, 61, 27, 2, 6, 7, 2, 10, 12, 2, 6, 64, 65, 67, 64, 65, 64, 65, 60, 61, 67, 20, 2, 6, 23, 2, 6, 64, 2, 6, 10, 2, 6, 20, 2, 26, 2, 6, 19, 2, 6, 55, 63, 23, 2, 6, 50, 2, 6, 62, 61, 66, 63, 50, 47, 45, 51, 52, 50, 2, 59, 66, 2, 52, 47, 47, 42, 27, 2, 26, 2, 7, 21, 2, 6, 18, 27, 2, 7, 21, 2, 11, 41, 48, 50, 47, 48, 54, 43, 46, 21, 2, 7, 29, 2, 11, 18, 43, 40, 27, 2, 7, 25, 40, 52, 40, 26, 2, 6, 25, 2, 8, 32, 23, 51, 53, 33, 2, 7, 15, 43, 44, 47, 48, 25, 45, 45, 42, 18, 2, 6, 14, 24, 48, 52, 41, 18, 25, 2, 7, 26, 23, 2, 6, 24, 46, 43, 39, 45, 2, 7, 21, 2, 8, 17, 2, 6, 14, 2, 6, 25, 2, 61, 2, 6, 44, 38, 2, 8, 23, 2, 6, 42, 45, 45, 2, 7, 24, 2, 8, 31, 2, 6, 36, 62, 41, 43, 42, 42, 49, 43, 45, 47, 28, 2, 8, 23, 44, 38, 46, 32, 2, 6, 16, 42, 40, 38, 46, 2, 9, 2, 7, 45, 2, 17, 14, 54, 45, 48, 42, 40, 42, 2, 11, 2, 2, 2, 33, 2, 29, 2, 6, 50, 39, 2, 6, 23, 2, 6, 47, 46, 49, 47, 43, 55, 42, 29, 2, 6, 23, 2, 6, 19, 43, 43, 47, 41, 40, 49, 38, 44, 48, 47, 43, 42, 31, 2, 6, 16, 2, 6, 49, 42, 2, 6, 16, 2, 6, 45, 42, 42, 42, 41, 45, 44, 44, 29, 2, 6, 19, 2, 6, 41, 40, 52, 48, 41, 44, 47, 43, 44, 28, 2, 6, 22, 2, 6, 40, 39, 42, 46, 57, 47, 49, 23, 2, 6, 42, 2, 6, 50, 47, 37, 44, 43, 22, 2, 6, 27, 2, 6, 50, 52, 46, 42, 53, 54, 39, 18, 2, 6, 46, 42, 2, 6, 40, 46, 36, 34, 36, 49, 48, 26, 2, 6, 24, 2, 16, 2, 6, 49, 2, 6, 52, 2, 6, 19, 2, 6, 65, 65, 67, 42, 2, 6, 56, 41, 2, 6, 58, 45, 2, 6, 39, 2, 6, 56, 2, 6, 42, 2, 6, 55, 2, 6, 63, 65, 58, 11, 2, 6, 28, 39, 2, 6, 61, 57, 61, 66, 66, 47, 2, 6, 61, 65, 64, 67, 67, 64, 45, 2, 6, 46, 2, 6, 64, 15, 2, 6, 6, 2, 6, 67, 14, 2, 6, 48, 2, 6, 13, 2, 6, 59, 2, 6, 14, 2, 6, 33, 2, 6, 63, 30, 2, 6, 55, 2, 6, 60, 58, 2, 6, 60, 43, 2, 6, 20, 2, 6, 20, 2, 6, 39, 2, 6, 58, 60, 67, 63, 63, 23, 2, 6, 30, 2, 6, 61, 2, 6, 38, 2, 6, 59, 67, 62, 67, 66, 2, 6, 58, 59, 63, 46, 2, 6, 21, 2, 6, 58, 2, 6, 62, 59, 64, 65, 25, 2, 6, 33, 2, 6, 60, 2, 6, 37, 2, 6, 15, 2, 15, 2, 63, 13, 2, 6, 52, 2, 6, 67, 67, 63, 60, 64, 43, 2, 17, 2, 7, 59, 66, 65, 24, 2, 6, 64, 67, 22, 2, 7, 45, 2, 6, 16, 2, 7, 59, 34, 2, 6, 24, 2, 14, 2, 6, 36, 2, 6, 61, 67, 63, 2, 6, 22, 2, 6, 60, 32, 2, 6, 64, 41, 2, 6, 61, 65, 66, 65, 29, 2, 64, 12, 2, 7, 49, 2, 46, 2, 6, 50, 39, 53, 42, 18, 47, 45, 45, 39, 47, 44, 45, 43, 37, 24, 41, 47, 42, 22, 2, 7, 27, 49, 42, 42, 44, 39, 45, 43, 24, 2, 6, 22, 47, 29, 2, 7, 19, 2, 6, 47, 53, 25, 2, 7, 19, 2, 6, 19, 2, 7, 50, 21, 2, 6, 21, 50, 2, 7, 41, 50, 2, 7, 40, 2, 6, 52, 2, 25, 2, 6, 19, 2, 7, 46, 41, 42, 46, 49, 41, 46, 49, 42, 39, 51, 50, 39, 2, 6, 15, 2, 7, 16, 2, 14, 2, 6, 6, 2, 7, 5, 2, 6, 11, 2, 6, 29, 2, 7, 15, 2, 7, 52, 25, 2, 47, 2, 19, 2, 6, 48, 35, 2, 14, 2, 7, 33, 2, 7, 20, 2, 8, 34, 46, 44, 2, 6, 13, 2, 7, 25, 2, 8, 40, 2, 7, 50, 2, 6, 41, 2, 8, 29, 2, 7, 28, 2, 7, 19, 2, 7, 53, 2, 6, 46, 42, 38, 2, 7, 22, 2, 14, 2, 6, 23, 2, 7, 18, 2, 50, 45, 2, 7, 31, 2, 6, 18, 2, 20, 2, 6, 30, 2, 6, 48, 2, 6, 20, 2, 7, 46, 45, 2, 6, 21, 2, 7, 31, 2, 8, 52, 39, 2, 9, 2, 6, 41, 25, 2, 18, 2, 7, 45, 44, 44, 44, 42, 43, 45, 48, 2, 6, 28, 27, 2, 19, 2, 18, 19, 2, 7, 43, 2, 6, 48, 44, 19, 2, 14, 2, 7, 22, 39, 45, 48, 18, 2, 9, 2, 6, 47, 47, 48, 45, 48, 50, 37, 44, 21, 2, 6, 19, 43, 30, 2, 6, 19, 52, 38, 53, 42, 35, 50, 21, 2, 36, 2, 29, 2, 6, 51, 37, 22, 2, 6, 20, 47, 46, 39, 39, 50, 45, 2, 9, 2, 6, 54, 46, 32, 2, 17, 2, 58, 2, 7, 22, 2, 6, 26, 47, 2, 7, 45, 45, 37, 26, 2, 15, 22, 45, 53, 42, 45, 34, 2, 6, 21, 42, 44, 47, 49, 48, 40, 45, 48, 39, 45, 47, 39, 48, 16, 2, 7, 26, 39, 43, 47, 48, 2, 6, 43, 51, 43, 54, 29, 2, 7, 19, 42, 40, 52, 42, 25, 43, 47, 29, 2, 17, 2, 65, 24]\n"
 370 |      ]
 371 |     }
 372 |    ],
 373 |    "source": [
 374 |     "linelengths=[len(line) for line in open(\"hamlet.txt\")]#poor code as we dont close the file\n",
 375 |     "print linelengths"
 376 |    ]
 377 |   },
 378 |   {
 379 |    "cell_type": "code",
 380 |    "execution_count": 14,
 381 |    "metadata": {
 382 |     "collapsed": false
 383 |    },
 384 |    "outputs": [
 385 |     {
 386 |      "data": {
 387 |       "text/plain": [
 388 |        "(180718, 26.69394387001477, 26.0, 21.029872021427462)"
 389 |       ]
 390 |      },
 391 |      "execution_count": 14,
 392 |      "metadata": {},
 393 |      "output_type": "execute_result"
 394 |     }
 395 |    ],
 396 |    "source": [
 397 |     "sum(linelengths), np.mean(linelengths), np.median(linelengths), np.std(linelengths)"
 398 |    ]
 399 |   },
 400 |   {
 401 |    "cell_type": "markdown",
 402 |    "metadata": {},
 403 |    "source": [
 404 |     "But perhaps we want to access Hamlet word by word and not line by line"
 405 |    ]
 406 |   },
 407 |   {
 408 |    "cell_type": "code",
 409 |    "execution_count": 15,
 410 |    "metadata": {
 411 |     "collapsed": false
 412 |    },
 413 |    "outputs": [
 414 |     {
 415 |      "data": {
 416 |       "text/plain": [
 417 |        "31659"
 418 |       ]
 419 |      },
 420 |      "execution_count": 15,
 421 |      "metadata": {},
 422 |      "output_type": "execute_result"
 423 |     }
 424 |    ],
 425 |    "source": [
 426 |     "hamletfile=open(\"hamlet.txt\")\n",
 427 |     "hamlettext=hamletfile.read()\n",
 428 |     "hamletfile.close()\n",
 429 |     "hamlettokens=hamlettext.split()#split with no arguments splits on whitespace\n",
 430 |     "len(hamlettokens)"
 431 |    ]
 432 |   },
 433 |   {
 434 |    "cell_type": "markdown",
 435 |    "metadata": {},
 436 |    "source": [
 437 |     "One can use the `with` syntax which cretaes a context. The file closing is then done automatically for us."
 438 |    ]
 439 |   },
 440 |   {
 441 |    "cell_type": "code",
 442 |    "execution_count": 15,
 443 |    "metadata": {
 444 |     "collapsed": false
 445 |    },
 446 |    "outputs": [
 447 |     {
 448 |      "name": "stdout",
 449 |      "output_type": "stream",
 450 |      "text": [
 451 |       "31659\n"
 452 |      ]
 453 |     }
 454 |    ],
 455 |    "source": [
 456 |     "with open(\"hamlet.txt\") as hamletfile:\n",
 457 |     "    hamlettext=hamletfile.read()\n",
 458 |     "    hamlettokens=hamlettext.split()\n",
 459 |     "    print len(hamlettokens)"
 460 |    ]
 461 |   },
 462 |   {
 463 |    "cell_type": "markdown",
 464 |    "metadata": {},
 465 |    "source": [
 466 |     "There are roughly 32,000 words in Hamlet."
 467 |    ]
 468 |   },
 469 |   {
 470 |    "cell_type": "markdown",
 471 |    "metadata": {},
 472 |    "source": [
 473 |     "###The indexing of lists"
 474 |    ]
 475 |   },
 476 |   {
 477 |    "cell_type": "code",
 478 |    "execution_count": 44,
 479 |    "metadata": {
 480 |     "collapsed": false
 481 |    },
 482 |    "outputs": [
 483 |     {
 484 |      "name": "stdout",
 485 |      "output_type": "stream",
 486 |      "text": [
 487 |       "XXXX\r\n",
 488 |       "HAMLET, PRINCE OF DENMARK\r\n",
 489 |       "\r\n",
 490 |       "by William Shakespeare\r\n",
 491 |       "\r\n",
 492 |       "\r\n",
 493 |       "\r\n",
 494 |       "\r\n",
 495 |       "PERSONS REPRESENTED.\r\n",
 496 |       "\r\n",
 497 |       "Claudius, King of Denmark.\r\n",
 498 |       "Hamlet, Son to the former, and Nephew to the present King.\r\n",
 499 |       "Polonius, Lord Chamberlain.\r\n",
 500 |       "Horatio, Friend to Hamlet.\r\n",
 501 |       "Laertes, Son to Polonius.\r\n",
 502 |       "Voltimand, Courtier.\r\n",
 503 |       "Cornelius, Courtier.\r\n",
 504 |       "Rosencrantz, Courtier.\r\n",
 505 |       "Guildenstern, Courtier.\r\n",
 506 |       "Osric, Courtier.\r\n",
 507 |       "A Gentleman, Courtier.\r\n",
 508 |       "A Priest.\r\n",
 509 |       "Marcellus, Officer.\r\n",
 510 |       "Bernardo, Officer.\r\n",
 511 |       "Francisco, a Soldier\r\n",
 512 |       "Reynaldo, Servant to Polonius.\r\n",
 513 |       "Players.\r\n",
 514 |       "Two Clowns, Grave-diggers.\r\n",
 515 |       "Fortinbras, Prince of Norway.\r\n",
 516 |       "A Captain.\r\n",
 517 |       "English Ambassadors.\r\n",
 518 |       "Ghost of Hamlet's Father.\r\n",
 519 |       "\r\n",
 520 |       "Gertrude, Queen of Denmark, and Mother of Hamlet.\r\n",
 521 |       "Ophelia, Daughter to Polonius.\r\n",
 522 |       "\r\n",
 523 |       "Lords, Ladies, Officers, Soldiers, Sailors, Messengers, and other\r\n",
 524 |       "Attendants.\r\n",
 525 |       "\r\n",
 526 |       "SCENE. Elsinore.\r\n",
 527 |       "\r\n",
 528 |       "\r\n",
 529 |       "\r\n",
 530 |       "ACT I.\r\n",
 531 |       "\r\n",
 532 |       "Scene I. Elsinore. A platform before the Castle.\r\n",
 533 |       "\r\n",
 534 |       "[Francisco at his post. Enter to him Bernardo.]\r\n",
 535 |       "\r\n",
 536 |       "Ber.\r\n",
 537 |       "Who's there?\r\n",
 538 |       "\r\n",
 539 |       "Fran.\r\n",
 540 |       "Nay, answer me: stand, and u\n"
 541 |      ]
 542 |     }
 543 |    ],
 544 |    "source": [
 545 |     "print hamlettext[:1000]#first 1000 characters from Hamlet."
 546 |    ]
 547 |   },
 548 |   {
 549 |    "cell_type": "code",
 550 |    "execution_count": 45,
 551 |    "metadata": {
 552 |     "collapsed": false
 553 |    },
 554 |    "outputs": [
 555 |     {
 556 |      "name": "stdout",
 557 |      "output_type": "stream",
 558 |      "text": [
 559 |       "nd, in this upshot, purposes mistook\r\n",
 560 |       "Fall'n on the inventors' heads: all this can I\r\n",
 561 |       "Truly deliver.\r\n",
 562 |       "\r\n",
 563 |       "Fort.\r\n",
 564 |       "Let us haste to hear it,\r\n",
 565 |       "And call the noblest to the audience.\r\n",
 566 |       "For me, with sorrow I embrace my fortune:\r\n",
 567 |       "I have some rights of memory in this kingdom,\r\n",
 568 |       "Which now, to claim my vantage doth invite me.\r\n",
 569 |       "\r\n",
 570 |       "Hor.\r\n",
 571 |       "Of that I shall have also cause to speak,\r\n",
 572 |       "And from his mouth whose voice will draw on more:\r\n",
 573 |       "But let this same be presently perform'd,\r\n",
 574 |       "Even while men's minds are wild: lest more mischance\r\n",
 575 |       "On plots and errors happen.\r\n",
 576 |       "\r\n",
 577 |       "Fort.\r\n",
 578 |       "Let four captains\r\n",
 579 |       "Bear Hamlet like a soldier to the stage;\r\n",
 580 |       "For he was likely, had he been put on,\r\n",
 581 |       "To have prov'd most royally: and, for his passage,\r\n",
 582 |       "The soldiers' music and the rites of war\r\n",
 583 |       "Speak loudly for him.--\r\n",
 584 |       "Take up the bodies.--Such a sight as this\r\n",
 585 |       "Becomes the field, but here shows much amiss.\r\n",
 586 |       "Go, bid the soldiers shoot.\r\n",
 587 |       "\r\n",
 588 |       "[A dead march.]\r\n",
 589 |       "\r\n",
 590 |       "[Exeunt, bearing off the dead bodies; after the which a peal of\r\n",
 591 |       "ordnance is shot off.]\r\n",
 592 |       "\n"
 593 |      ]
 594 |     }
 595 |    ],
 596 |    "source": [
 597 |     "print hamlettext[-1000:]#and last 1000 characters from Hamlet."
 598 |    ]
 599 |   },
 600 |   {
 601 |    "cell_type": "markdown",
 602 |    "metadata": {},
 603 |    "source": [
 604 |     "Lets split the word tokens. The first one below reads, give me the second, third, and fourth words (remember that python is 0 indexed). Try and figure what the others mean."
 605 |    ]
 606 |   },
 607 |   {
 608 |    "cell_type": "code",
 609 |    "execution_count": 16,
 610 |    "metadata": {
 611 |     "collapsed": false
 612 |    },
 613 |    "outputs": [
 614 |     {
 615 |      "name": "stdout",
 616 |      "output_type": "stream",
 617 |      "text": [
 618 |       "['HAMLET,', 'PRINCE', 'OF'] ['\\xef\\xbb\\xbfXXXX', 'HAMLET,', 'PRINCE', 'OF'] XXXX off.]\n"
 619 |      ]
 620 |     }
 621 |    ],
 622 |    "source": [
 623 |     "print hamlettokens[1:4], hamlettokens[:4], hamlettokens[0], hamlettokens[-1]"
 624 |    ]
 625 |   },
 626 |   {
 627 |    "cell_type": "code",
 628 |    "execution_count": 17,
 629 |    "metadata": {
 630 |     "collapsed": false
 631 |    },
 632 |    "outputs": [
 633 |     {
 634 |      "data": {
 635 |       "text/plain": [
 636 |        "['HAMLET,', 'OF', 'by', 'Shakespeare']"
 637 |       ]
 638 |      },
 639 |      "execution_count": 17,
 640 |      "metadata": {},
 641 |      "output_type": "execute_result"
 642 |     }
 643 |    ],
 644 |    "source": [
 645 |     "hamlettokens[1:8:2]#get every 2nd world between the 2nd and the 9th: ie 2nd, 4th, 6th, and 8th"
 646 |    ]
 647 |   },
 648 |   {
 649 |    "cell_type": "markdown",
 650 |    "metadata": {},
 651 |    "source": [
 652 |     "range and xrange get the list of integers upto N. But xrange behaves like an iterator. The reason for this is that there is no point generaing all os a million integers. We can just add 1 to the previous one and save memory. So we trade off storage for computation."
 653 |    ]
 654 |   },
 655 |   {
 656 |    "cell_type": "code",
 657 |    "execution_count": 18,
 658 |    "metadata": {
 659 |     "collapsed": false
 660 |    },
 661 |    "outputs": [
 662 |     {
 663 |      "data": {
 664 |       "text/plain": [
 665 |        "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
 666 |       ]
 667 |      },
 668 |      "execution_count": 18,
 669 |      "metadata": {},
 670 |      "output_type": "execute_result"
 671 |     }
 672 |    ],
 673 |    "source": [
 674 |     "mylist=[]\n",
 675 |     "for i in xrange(10):\n",
 676 |     "    mylist.append(i)\n",
 677 |     "mylist"
 678 |    ]
 679 |   },
 680 |   {
 681 |    "cell_type": "markdown",
 682 |    "metadata": {},
 683 |    "source": [
 684 |     "## Dictionaries\n",
 685 |     "\n",
 686 |     "These are the bread and butter. You will use them a lot. They even duck like lists. But be careful how."
 687 |    ]
 688 |   },
 689 |   {
 690 |    "cell_type": "code",
 691 |    "execution_count": 19,
 692 |    "metadata": {
 693 |     "collapsed": false
 694 |    },
 695 |    "outputs": [
 696 |     {
 697 |      "name": "stdout",
 698 |      "output_type": "stream",
 699 |      "text": [
 700 |       "['three', 'two', 'one'] [('three', 3), ('two', 2), ('one', 1)] [3, 2, 1]\n"
 701 |      ]
 702 |     }
 703 |    ],
 704 |    "source": [
 705 |     "adict={'one':1, 'two': 2, 'three': 3}\n",
 706 |     "print [i for i in adict], [(k,v) for k,v in adict.items()], adict.values()"
 707 |    ]
 708 |   },
 709 |   {
 710 |    "cell_type": "markdown",
 711 |    "metadata": {},
 712 |    "source": [
 713 |     "The keys do not have to be strings. From python 2.7 you can use dictionary comprehensions as well"
 714 |    ]
 715 |   },
 716 |   {
 717 |    "cell_type": "code",
 718 |    "execution_count": 20,
 719 |    "metadata": {
 720 |     "collapsed": false
 721 |    },
 722 |    "outputs": [
 723 |     {
 724 |      "data": {
 725 |       "text/plain": [
 726 |        "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}"
 727 |       ]
 728 |      },
 729 |      "execution_count": 20,
 730 |      "metadata": {},
 731 |      "output_type": "execute_result"
 732 |     }
 733 |    ],
 734 |    "source": [
 735 |     "mydict ={k:v for (k,v) in zip(alist, asquaredlist)}\n",
 736 |     "mydict"
 737 |    ]
 738 |   },
 739 |   {
 740 |    "cell_type": "markdown",
 741 |    "metadata": {},
 742 |    "source": [
 743 |     "You can construct then nicely using the function `dict`."
 744 |    ]
 745 |   },
 746 |   {
 747 |    "cell_type": "code",
 748 |    "execution_count": 46,
 749 |    "metadata": {
 750 |     "collapsed": false
 751 |    },
 752 |    "outputs": [
 753 |     {
 754 |      "data": {
 755 |       "text/plain": [
 756 |        "{'a': 1, 'b': 2}"
 757 |       ]
 758 |      },
 759 |      "execution_count": 46,
 760 |      "metadata": {},
 761 |      "output_type": "execute_result"
 762 |     }
 763 |    ],
 764 |    "source": [
 765 |     "dict(a=1, b=2)"
 766 |    ]
 767 |   },
 768 |   {
 769 |    "cell_type": "markdown",
 770 |    "metadata": {},
 771 |    "source": [
 772 |     "###and conversion to json"
 773 |    ]
 774 |   },
 775 |   {
 776 |    "cell_type": "code",
 777 |    "execution_count": 21,
 778 |    "metadata": {
 779 |     "collapsed": false
 780 |    },
 781 |    "outputs": [],
 782 |    "source": [
 783 |     "import json"
 784 |    ]
 785 |   },
 786 |   {
 787 |    "cell_type": "code",
 788 |    "execution_count": 22,
 789 |    "metadata": {
 790 |     "collapsed": false
 791 |    },
 792 |    "outputs": [
 793 |     {
 794 |      "name": "stdout",
 795 |      "output_type": "stream",
 796 |      "text": [
 797 |       "{\"1\": 1, \"2\": 4, \"3\": 9, \"4\": 16, \"5\": 25}\n"
 798 |      ]
 799 |     }
 800 |    ],
 801 |    "source": [
 802 |     "s=json.dumps(mydict)\n",
 803 |     "print s"
 804 |    ]
 805 |   },
 806 |   {
 807 |    "cell_type": "code",
 808 |    "execution_count": 23,
 809 |    "metadata": {
 810 |     "collapsed": false
 811 |    },
 812 |    "outputs": [
 813 |     {
 814 |      "data": {
 815 |       "text/plain": [
 816 |        "{u'1': 1, u'2': 4, u'3': 9, u'4': 16, u'5': 25}"
 817 |       ]
 818 |      },
 819 |      "execution_count": 23,
 820 |      "metadata": {},
 821 |      "output_type": "execute_result"
 822 |     }
 823 |    ],
 824 |    "source": [
 825 |     "json.loads(s)"
 826 |    ]
 827 |   },
 828 |   {
 829 |    "cell_type": "markdown",
 830 |    "metadata": {},
 831 |    "source": [
 832 |     "## Strings\n",
 833 |     "\n",
 834 |     "Basically they behave like immutable lists"
 835 |    ]
 836 |   },
 837 |   {
 838 |    "cell_type": "code",
 839 |    "execution_count": 24,
 840 |    "metadata": {
 841 |     "collapsed": false
 842 |    },
 843 |    "outputs": [
 844 |     {
 845 |      "name": "stdout",
 846 |      "output_type": "stream",
 847 |      "text": [
 848 |       "off.]\n"
 849 |      ]
 850 |     }
 851 |    ],
 852 |    "source": [
 853 |     "lastword=hamlettokens[-1]\n",
 854 |     "print(lastword)"
 855 |    ]
 856 |   },
 857 |   {
 858 |    "cell_type": "code",
 859 |    "execution_count": 25,
 860 |    "metadata": {
 861 |     "collapsed": false
 862 |    },
 863 |    "outputs": [
 864 |     {
 865 |      "ename": "TypeError",
 866 |      "evalue": "'str' object does not support item assignment",
 867 |      "output_type": "error",
 868 |      "traceback": [
 869 |       "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
 870 |       "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
 871 |       "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mlastword\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"k\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
 872 |       "\u001b[0;31mTypeError\u001b[0m: 'str' object does not support item assignment"
 873 |      ]
 874 |     }
 875 |    ],
 876 |    "source": [
 877 |     "lastword[-2]=\"k\"#cant change a part of a string"
 878 |    ]
 879 |   },
 880 |   {
 881 |    "cell_type": "code",
 882 |    "execution_count": 26,
 883 |    "metadata": {
 884 |     "collapsed": false
 885 |    },
 886 |    "outputs": [
 887 |     {
 888 |      "data": {
 889 |       "text/plain": [
 890 |        "'.'"
 891 |       ]
 892 |      },
 893 |      "execution_count": 26,
 894 |      "metadata": {},
 895 |      "output_type": "execute_result"
 896 |     }
 897 |    ],
 898 |    "source": [
 899 |     "lastword[-2]"
 900 |    ]
 901 |   },
 902 |   {
 903 |    "cell_type": "code",
 904 |    "execution_count": null,
 905 |    "metadata": {
 906 |     "collapsed": true
 907 |    },
 908 |    "outputs": [],
 909 |    "source": [
 910 |     "You can join a list with a separator to make a string."
 911 |    ]
 912 |   },
 913 |   {
 914 |    "cell_type": "code",
 915 |    "execution_count": 27,
 916 |    "metadata": {
 917 |     "collapsed": false
 918 |    },
 919 |    "outputs": [
 920 |     {
 921 |      "data": {
 922 |       "text/plain": [
 923 |        "\"\\xef\\xbb\\xbfXXXX,HAMLET,,PRINCE,OF,DENMARK,by,William,Shakespeare,PERSONS,REPRESENTED.,Claudius,,King,of,Denmark.,Hamlet,,Son,to,the,former,,and,Nephew,to,the,present,King.,Polonius,,Lord,Chamberlain.,Horatio,,Friend,to,Hamlet.,Laertes,,Son,to,Polonius.,Voltimand,,Courtier.,Cornelius,,Courtier.,Rosencrantz,,Courtier.,Guildenstern,,Courtier.,Osric,,Courtier.,A,Gentleman,,Courtier.,A,Priest.,Marcellus,,Officer.,Bernardo,,Officer.,Francisco,,a,Soldier,Reynaldo,,Servant,to,Polonius.,Players.,Two,Clowns,,Grave-diggers.,Fortinbras,,Prince,of,Norway.,A,Captain.,English,Ambassadors.,Ghost,of,Hamlet's,Father.,Gertrude,,Queen,of,Denmark,,and,Mother,of,Hamlet.,Ophelia,,Daughter,to,Polonius.,Lords,,Ladies,,Officers,,Soldiers,,Sailors,,Messengers,,and,other,Attendants.,SCENE.,Elsinore.,ACT,I.,Scene,I.,Elsinore.,A,platform,before,the,Castle.,[Francisco,at,his,post.,Enter,to,him,Bernardo.],Ber.,Who's,there?,Fran.,Nay,,answer,me:,stand,,and,unfold,yourself.,Ber.,Long,live,the,king!,Fran.,Bernardo?,Ber.,He.,Fra\""
 924 |       ]
 925 |      },
 926 |      "execution_count": 27,
 927 |      "metadata": {},
 928 |      "output_type": "execute_result"
 929 |     }
 930 |    ],
 931 |    "source": [
 932 |     "wierdstring=\",\".join(hamlettokens)\n",
 933 |     "wierdstring[:1000]"
 934 |    ]
 935 |   },
 936 |   {
 937 |    "cell_type": "markdown",
 938 |    "metadata": {},
 939 |    "source": [
 940 |     "## Functions\n",
 941 |     "\n",
 942 |     "Functions are even more the bread and butter. You'll see them as methods on objects, or standing alone by themselves."
 943 |    ]
 944 |   },
 945 |   {
 946 |    "cell_type": "code",
 947 |    "execution_count": 28,
 948 |    "metadata": {
 949 |     "collapsed": false
 950 |    },
 951 |    "outputs": [
 952 |     {
 953 |      "data": {
 954 |       "text/plain": [
 955 |        "(25, 125)"
 956 |       ]
 957 |      },
 958 |      "execution_count": 28,
 959 |      "metadata": {},
 960 |      "output_type": "execute_result"
 961 |     }
 962 |    ],
 963 |    "source": [
 964 |     "def square(x):\n",
 965 |     "    return(x*x)\n",
 966 |     "def cube(x):\n",
 967 |     "    return x*x*x\n",
 968 |     "square(5),cube(5)"
 969 |    ]
 970 |   },
 971 |   {
 972 |    "cell_type": "code",
 973 |    "execution_count": 29,
 974 |    "metadata": {
 975 |     "collapsed": false
 976 |    },
 977 |    "outputs": [
 978 |     {
 979 |      "name": "stdout",
 980 |      "output_type": "stream",
 981 |      "text": [
 982 |       " \n"
 983 |      ]
 984 |     }
 985 |    ],
 986 |    "source": [
 987 |     "print square, type(cube)"
 988 |    ]
 989 |   },
 990 |   {
 991 |    "cell_type": "markdown",
 992 |    "metadata": {},
 993 |    "source": [
 994 |     "In Python, functions are \"first-class\". This is just a fancy way of saying, you can pass functions to other functions"
 995 |    ]
 996 |   },
 997 |   {
 998 |    "cell_type": "code",
 999 |    "execution_count": 47,
1000 |    "metadata": {
1001 |     "collapsed": false
1002 |    },
1003 |    "outputs": [
1004 |     {
1005 |      "name": "stdout",
1006 |      "output_type": "stream",
1007 |      "text": [
1008 |       "3 4 \n"
1009 |      ]
1010 |     },
1011 |     {
1012 |      "data": {
1013 |       "text/plain": [
1014 |        "25"
1015 |       ]
1016 |      },
1017 |      "execution_count": 47,
1018 |      "metadata": {},
1019 |      "output_type": "execute_result"
1020 |     }
1021 |    ],
1022 |    "source": [
1023 |     "def sum_of_anything(x,y,f):\n",
1024 |     "    print x,y,f\n",
1025 |     "    return(f(x) + f(y))\n",
1026 |     "sum_of_anything(3,4,square)"
1027 |    ]
1028 |   },
1029 |   {
1030 |    "cell_type": "markdown",
1031 |    "metadata": {},
1032 |    "source": [
1033 |     "Python functions can have positional arguments and keyword arguments. Positional arguments are stored in a tuple, and keyword arguments in a dictionary. Note the \"starred\" syntax"
1034 |    ]
1035 |   },
1036 |   {
1037 |    "cell_type": "code",
1038 |    "execution_count": 50,
1039 |    "metadata": {
1040 |     "collapsed": false
1041 |    },
1042 |    "outputs": [
1043 |     {
1044 |      "name": "stdout",
1045 |      "output_type": "stream",
1046 |      "text": [
1047 |       "got 1 3 () {}\n",
1048 |       "1\n",
1049 |       "got 1 3 (4,) {'c': 2, 'd': 1}\n",
1050 |       "1\n"
1051 |      ]
1052 |     }
1053 |    ],
1054 |    "source": [
1055 |     "def f(a,b,*posargs,**dictargs):\n",
1056 |     "    print \"got\",a,b,posargs, dictargs\n",
1057 |     "    return a\n",
1058 |     "print f(1,3)\n",
1059 |     "print f(1,3,4,d=1,c=2)"
1060 |    ]
1061 |   },
1062 |   {
1063 |    "cell_type": "markdown",
1064 |    "metadata": {},
1065 |    "source": [
1066 |     ">**YOUR TURN** create a dictionary with keys the integers upto and including 10, and values the cubes of these dictionaries"
1067 |    ]
1068 |   },
1069 |   {
1070 |    "cell_type": "code",
1071 |    "execution_count": null,
1072 |    "metadata": {
1073 |     "collapsed": false
1074 |    },
1075 |    "outputs": [],
1076 |    "source": [
1077 |     "#your code here"
1078 |    ]
1079 |   },
1080 |   {
1081 |    "cell_type": "markdown",
1082 |    "metadata": {},
1083 |    "source": [
1084 |     "##Booleans and Control-flow\n",
1085 |     "\n",
1086 |     "Lets test for belonging..."
1087 |    ]
1088 |   },
1089 |   {
1090 |    "cell_type": "code",
1091 |    "execution_count": 32,
1092 |    "metadata": {
1093 |     "collapsed": false
1094 |    },
1095 |    "outputs": [
1096 |     {
1097 |      "data": {
1098 |       "text/plain": [
1099 |        "True"
1100 |       ]
1101 |      },
1102 |      "execution_count": 32,
1103 |      "metadata": {},
1104 |      "output_type": "execute_result"
1105 |     }
1106 |    ],
1107 |    "source": [
1108 |     "a=[1,2,3,4,5]\n",
1109 |     "1 in a"
1110 |    ]
1111 |   },
1112 |   {
1113 |    "cell_type": "code",
1114 |    "execution_count": 33,
1115 |    "metadata": {
1116 |     "collapsed": false
1117 |    },
1118 |    "outputs": [
1119 |     {
1120 |      "data": {
1121 |       "text/plain": [
1122 |        "False"
1123 |       ]
1124 |      },
1125 |      "execution_count": 33,
1126 |      "metadata": {},
1127 |      "output_type": "execute_result"
1128 |     }
1129 |    ],
1130 |    "source": [
1131 |     "6 in a"
1132 |    ]
1133 |   },
1134 |   {
1135 |    "cell_type": "markdown",
1136 |    "metadata": {},
1137 |    "source": [
1138 |     "Python supports if/elif/else clauses for multi-way conditionals"
1139 |    ]
1140 |   },
1141 |   {
1142 |    "cell_type": "code",
1143 |    "execution_count": 34,
1144 |    "metadata": {
1145 |     "collapsed": false
1146 |    },
1147 |    "outputs": [
1148 |     {
1149 |      "name": "stdout",
1150 |      "output_type": "stream",
1151 |      "text": [
1152 |       "One\n"
1153 |      ]
1154 |     }
1155 |    ],
1156 |    "source": [
1157 |     "def do_it(x):\n",
1158 |     "    if x==1:\n",
1159 |     "        print \"One\"\n",
1160 |     "    elif x==2:\n",
1161 |     "        print \"Two\"\n",
1162 |     "    else:\n",
1163 |     "        print x\n",
1164 |     "do_it(1)"
1165 |    ]
1166 |   },
1167 |   {
1168 |    "cell_type": "code",
1169 |    "execution_count": 35,
1170 |    "metadata": {
1171 |     "collapsed": false
1172 |    },
1173 |    "outputs": [
1174 |     {
1175 |      "name": "stdout",
1176 |      "output_type": "stream",
1177 |      "text": [
1178 |       "Two\n",
1179 |       "3\n"
1180 |      ]
1181 |     },
1182 |     {
1183 |      "data": {
1184 |       "text/plain": [
1185 |        "(None, None)"
1186 |       ]
1187 |      },
1188 |      "execution_count": 35,
1189 |      "metadata": {},
1190 |      "output_type": "execute_result"
1191 |     }
1192 |    ],
1193 |    "source": [
1194 |     "do_it(2), do_it(3)"
1195 |    ]
1196 |   },
1197 |   {
1198 |    "cell_type": "markdown",
1199 |    "metadata": {},
1200 |    "source": [
1201 |     "You can `break` out of a loop based on a condition. The loop below is a for loop."
1202 |    ]
1203 |   },
1204 |   {
1205 |    "cell_type": "code",
1206 |    "execution_count": 36,
1207 |    "metadata": {
1208 |     "collapsed": false
1209 |    },
1210 |    "outputs": [
1211 |     {
1212 |      "name": "stdout",
1213 |      "output_type": "stream",
1214 |      "text": [
1215 |       "0\n",
1216 |       "1\n",
1217 |       "2\n",
1218 |       "3\n",
1219 |       "4\n",
1220 |       "5\n",
1221 |       "6\n"
1222 |      ]
1223 |     }
1224 |    ],
1225 |    "source": [
1226 |     "for i in range(10):\n",
1227 |     "    print i\n",
1228 |     "    if (i > 5):\n",
1229 |     "        break"
1230 |    ]
1231 |   },
1232 |   {
1233 |    "cell_type": "markdown",
1234 |    "metadata": {},
1235 |    "source": [
1236 |     "While loops are also supported. `continue` continues to the next iteration of the loop skipping all the code below, while `break` breaks out of it."
1237 |    ]
1238 |   },
1239 |   {
1240 |    "cell_type": "code",
1241 |    "execution_count": 37,
1242 |    "metadata": {
1243 |     "collapsed": false
1244 |    },
1245 |    "outputs": [
1246 |     {
1247 |      "name": "stdout",
1248 |      "output_type": "stream",
1249 |      "text": [
1250 |       "0\n",
1251 |       "1\n",
1252 |       "2\n",
1253 |       "3\n",
1254 |       "4\n"
1255 |      ]
1256 |     }
1257 |    ],
1258 |    "source": [
1259 |     "i=0\n",
1260 |     "while i < 10:\n",
1261 |     "    print i\n",
1262 |     "    i=i+1\n",
1263 |     "    if i < 5:\n",
1264 |     "        continue\n",
1265 |     "    else:\n",
1266 |     "        break\n"
1267 |    ]
1268 |   },
1269 |   {
1270 |    "cell_type": "markdown",
1271 |    "metadata": {},
1272 |    "source": [
1273 |     "## Exceptions\n",
1274 |     "\n",
1275 |     "This is the way to catch errors."
1276 |    ]
1277 |   },
1278 |   {
1279 |    "cell_type": "code",
1280 |    "execution_count": 38,
1281 |    "metadata": {
1282 |     "collapsed": false
1283 |    },
1284 |    "outputs": [
1285 |     {
1286 |      "name": "stdout",
1287 |      "output_type": "stream",
1288 |      "text": [
1289 |       "(, TypeError('f() takes at least 2 arguments (1 given)',), )\n"
1290 |      ]
1291 |     }
1292 |    ],
1293 |    "source": [
1294 |     "try:\n",
1295 |     "    f(1)#takes atleast 2 arguments\n",
1296 |     "except:\n",
1297 |     "    import sys\n",
1298 |     "    print sys.exc_info()"
1299 |    ]
1300 |   },
1301 |   {
1302 |    "cell_type": "markdown",
1303 |    "metadata": {},
1304 |    "source": [
1305 |     "## All together now\n",
1306 |     "\n",
1307 |     "Lets see what hamlet gives us. We convert all words to lower-case"
1308 |    ]
1309 |   },
1310 |   {
1311 |    "cell_type": "code",
1312 |    "execution_count": 39,
1313 |    "metadata": {
1314 |     "collapsed": false
1315 |    },
1316 |    "outputs": [
1317 |     {
1318 |      "data": {
1319 |       "text/plain": [
1320 |        "95"
1321 |       ]
1322 |      },
1323 |      "execution_count": 39,
1324 |      "metadata": {},
1325 |      "output_type": "execute_result"
1326 |     }
1327 |    ],
1328 |    "source": [
1329 |     "hamletlctokens=[word.lower() for word in hamlettokens]\n",
1330 |     "hamletlctokens.count(\"thou\")"
1331 |    ]
1332 |   },
1333 |   {
1334 |    "cell_type": "markdown",
1335 |    "metadata": {},
1336 |    "source": [
1337 |     "We then find a unique set of words using python's `set` data structure. We count how often those words occured usinf the `count` method on lists."
1338 |    ]
1339 |   },
1340 |   {
1341 |    "cell_type": "code",
1342 |    "execution_count": 52,
1343 |    "metadata": {
1344 |     "collapsed": false
1345 |    },
1346 |    "outputs": [],
1347 |    "source": [
1348 |     "uniquelctokens=set(hamletlctokens)"
1349 |    ]
1350 |   },
1351 |   {
1352 |    "cell_type": "code",
1353 |    "execution_count": 41,
1354 |    "metadata": {
1355 |     "collapsed": false
1356 |    },
1357 |    "outputs": [],
1358 |    "source": [
1359 |     "tokendict={}\n",
1360 |     "for ut in uniquelctokens:\n",
1361 |     "    tokendict[ut]=hamletlctokens.count(ut)"
1362 |    ]
1363 |   },
1364 |   {
1365 |    "cell_type": "markdown",
1366 |    "metadata": {},
1367 |    "source": [
1368 |     "We find the 100 most used words..."
1369 |    ]
1370 |   },
1371 |   {
1372 |    "cell_type": "code",
1373 |    "execution_count": 42,
1374 |    "metadata": {
1375 |     "collapsed": false
1376 |    },
1377 |    "outputs": [
1378 |     {
1379 |      "data": {
1380 |       "text/plain": [
1381 |        "[('the', 1136),\n",
1382 |        " ('and', 943),\n",
1383 |        " ('to', 720),\n",
1384 |        " ('of', 667),\n",
1385 |        " ('a', 527),\n",
1386 |        " ('my', 512),\n",
1387 |        " ('i', 510),\n",
1388 |        " ('in', 420),\n",
1389 |        " ('you', 412),\n",
1390 |        " ('ham.', 358),\n",
1391 |        " ('that', 337),\n",
1392 |        " ('it', 324),\n",
1393 |        " ('is', 320),\n",
1394 |        " ('his', 295),\n",
1395 |        " ('not', 270),\n",
1396 |        " ('with', 264),\n",
1397 |        " ('this', 250),\n",
1398 |        " ('your', 241),\n",
1399 |        " ('for', 231),\n",
1400 |        " ('but', 228),\n",
1401 |        " ('as', 216),\n",
1402 |        " ('he', 202),\n",
1403 |        " ('be', 201),\n",
1404 |        " ('what', 183),\n",
1405 |        " ('have', 174),\n",
1406 |        " ('will', 149),\n",
1407 |        " ('so', 143),\n",
1408 |        " ('me', 142),\n",
1409 |        " ('we', 132),\n",
1410 |        " ('do', 128),\n",
1411 |        " ('are', 126),\n",
1412 |        " ('him', 122),\n",
1413 |        " ('our', 119),\n",
1414 |        " ('king.', 113),\n",
1415 |        " ('by', 111),\n",
1416 |        " ('hor.', 110),\n",
1417 |        " ('or', 109),\n",
1418 |        " ('if', 109),\n",
1419 |        " ('on', 109),\n",
1420 |        " ('no', 107),\n",
1421 |        " ('shall', 106),\n",
1422 |        " ('thou', 95),\n",
1423 |        " ('all', 95),\n",
1424 |        " ('from', 95),\n",
1425 |        " ('they', 93),\n",
1426 |        " ('let', 92),\n",
1427 |        " ('good', 88),\n",
1428 |        " ('at', 86),\n",
1429 |        " ('thy', 86),\n",
1430 |        " ('pol.', 86),\n",
1431 |        " ('how', 84),\n",
1432 |        " ('most', 82),\n",
1433 |        " ('lord,', 81),\n",
1434 |        " ('her', 76),\n",
1435 |        " ('more', 76),\n",
1436 |        " ('queen.', 76),\n",
1437 |        " ('like', 75),\n",
1438 |        " ('would', 74),\n",
1439 |        " ('was', 73),\n",
1440 |        " (\"'tis\", 70),\n",
1441 |        " ('you,', 66),\n",
1442 |        " ('may', 65),\n",
1443 |        " ('very', 64),\n",
1444 |        " ('laer.', 62),\n",
1445 |        " ('hath', 62),\n",
1446 |        " ('[enter', 61),\n",
1447 |        " ('lord.', 60),\n",
1448 |        " ('did', 59),\n",
1449 |        " ('give', 58),\n",
1450 |        " ('must', 58),\n",
1451 |        " ('oph.', 58),\n",
1452 |        " ('their', 57),\n",
1453 |        " ('o,', 57),\n",
1454 |        " ('know', 57),\n",
1455 |        " (\"i'll\", 56),\n",
1456 |        " ('an', 55),\n",
1457 |        " ('should', 55),\n",
1458 |        " ('which', 55),\n",
1459 |        " ('some', 54),\n",
1460 |        " ('when', 54),\n",
1461 |        " ('come', 54),\n",
1462 |        " ('upon', 53),\n",
1463 |        " ('make', 53),\n",
1464 |        " ('am', 52),\n",
1465 |        " ('such', 51),\n",
1466 |        " ('ros.', 51),\n",
1467 |        " ('than', 51),\n",
1468 |        " ('there', 50),\n",
1469 |        " ('where', 49),\n",
1470 |        " ('now', 48),\n",
1471 |        " ('go', 48),\n",
1472 |        " ('o', 46),\n",
1473 |        " ('us', 46),\n",
1474 |        " ('clown.', 45),\n",
1475 |        " ('much', 44),\n",
1476 |        " ('had', 44),\n",
1477 |        " ('these', 44),\n",
1478 |        " ('them', 44),\n",
1479 |        " ('she', 43),\n",
1480 |        " ('out', 43)]"
1481 |       ]
1482 |      },
1483 |      "execution_count": 42,
1484 |      "metadata": {},
1485 |      "output_type": "execute_result"
1486 |     }
1487 |    ],
1488 |    "source": [
1489 |     "L=sorted(tokendict.iteritems(), key= lambda (k,v):v, reverse=True)[:100]\n",
1490 |     "L"
1491 |    ]
1492 |   },
1493 |   {
1494 |    "cell_type": "markdown",
1495 |    "metadata": {},
1496 |    "source": [
1497 |     "Lets get the top 20 of this and plot a bar chart!"
1498 |    ]
1499 |   },
1500 |   {
1501 |    "cell_type": "code",
1502 |    "execution_count": 43,
1503 |    "metadata": {
1504 |     "collapsed": false
1505 |    },
1506 |    "outputs": [
1507 |     {
1508 |      "name": "stdout",
1509 |      "output_type": "stream",
1510 |      "text": [
1511 |       "[('the', 1136), ('and', 943), ('to', 720), ('of', 667), ('a', 527), ('my', 512), ('i', 510), ('in', 420), ('you', 412), ('ham.', 358), ('that', 337), ('it', 324), ('is', 320), ('his', 295), ('not', 270), ('with', 264), ('this', 250), ('your', 241), ('for', 231), ('but', 228)]\n"
1512 |      ]
1513 |     },
1514 |     {
1515 |      "data": {
1516 |       "image/png": "iVBORw0KGgoAAAANSUhEUgAAAegAAAFVCAYAAAAkBHynAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtcVHXi//H3cNNgwMTQVIyUyOwCLYmleW1bc7ceVhYV\nGGyPtUxbXQu3stLQpGwzYy3dtLRsJ1dlW9pqu2wbm+GltLatbC0zKqQbqGjNDMoMzvz+6Ov8vAIz\nzNEP8Hr+pWfOvM9nPszhzTlnLja/3+8XAAAwSsTxHgAAADgcBQ0AgIEoaAAADERBAwBgIAoaAAAD\nUdAAABioyYL+8MMPlZeXJ0n65JNPNHbsWOXl5WncuHHauXOnJKmkpERXXXWVrr32Wq1evVqStHfv\nXk2ePFljx47V+PHjVVtba92jAACgjWm0oJ988klNnz5dXq9XkvTAAw9oxowZcjgcGj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nR0tB555JFm/ewkae3atXrr\nrbdUV1enSZMmadasWXrttdcUExOjhx9+WKmpqaqurtbu3bt133336d5772129oGMLOiJEydq69at\nGjJkiKqrqzV79mxt3LhRS5YsUWZmphYsWKDS0lJ16NBBd9xxh9avX69BgwY1mrlt2zZdeuml+sUv\nfqGamhpdf/316tatmzIyMnT33XeruLhY//jHP3ThhRdqw4YNKi0tVX19vS677LKQx+9yuTR48GDl\n5eWpurpaubm5KisrC3VatGrVKp100kl6+OGH5Xa7NWbMGI0YMUKnn356i8tZOniOqqurm/yF3pi6\nujotXbpUr7zyipYtW6aSkhJt2LBBy5YtU2VlpX788UdVV1crMTGxReUshf/o0mazyWaz6auvvtLT\nTz+tjh076uKLL9bOnTvVpUuXZudcc801WrFihYYNG6bnnntOGRkZcjqdmjt3buDnN3DgwGY9Fr/f\nr+joaC1dulTffPONxo8fr8svv1xPPPGEOnbsqHvvvVdr165Vt27dVF1drRdeeEEff/yxpkyZojfe\neEPff/+9Jk2a1OjPs7H9bvjw4dq9e7eWLVsmm82mcePGadOmTYH7BFvO+x9rdna2Xn755aB+OTYn\nt6qqSj/88IOefPJJ1dbW6ssvvwwp69B5v+mmmwI/o5dfflk33nijRo4cqb///e9yuVxBHaW5XC4t\nXbpUlZWVuvnmmxUXF6f7779fZ5xxhsrKyjRnzhw9+uijevzxx5ucn5///Odas2aNunXrpl69emnd\nunWKiYnR4MGD9e233+qss87S0KFDdemll6p79+6qq6vT1KlT1aNHD+Xl5Wnz5s1KT08/YnZjz4sR\nI0YE5uP555/XzJkzdfbZZ2vFihXat2+fIiMjj5jZ0n1jx44dev7554/6R8V+M2fOVEFBgeLi4nTh\nhRce9ru4rq5Ov/3tb3XGGWc0mnMgv9+vxMREPfzww9q5c6eys7MPG6fNZtOECRP07LPPhlzOkqEF\nfeBnp5x55pmSpC5dumjPnj2qrKxUbW1t4K8mt9utqqqqJjO7dOmiZ555Rq+//rrsdnvgmk6/fv0k\nSd27d9eOHTv05Zdf6qyzzpIkdejQQeecc46C/SyX/et/8cUXGj16tCSpW7dustvtqq2tVWJiYlB5\n+33xxReBP0Ti4uLUp08fbdu2TWlpaSHlHerQOQr1OpvNZgvMq91uV2pqqiQpISFBXq9Xo0eP1ksv\nvaSvv/76sCe3SU499VTFxsZKkpKSklRfXx/U/QcMGKCioiLV1tZq/fr1Ou+88w76+aWmph723D3a\nqUybzRbYF0466aTAUeydd96p2NhYffnll/rZz34mSUpLS1NkZKTsdrt69eqlqKgoJSQkNDn+xvY7\nm82m6OhoFRQUKDY2VtXV1dq3b1/Q+8axcsopp2jEiBGaOnWqGhoalJeXF1LOofO+d+/eQFHcdddd\nWrx4sRwOh/r06RPUH8kH7iMnn3yyPB6P6urqAkXRv3//oF5zMHLkSD3++OPq0aOHbrvtNjkcDvl8\nPp111llHfA1Np06d1KNHD0k/Pbf37t171OzGnhcHmjNnjp566il9/fXXOvfccxt9brR030hOTm6y\nnA8c+5F+F+/cuVOSgv50S5vNpqysLEk/zYPdbj9orOHcJ4y8Br3/W6+kw48okpOT1b17dy1btkwO\nh0O5ubk699xzm8x8+umnde6552ru3Lm65JJLjrreaaedpo8++kg+n08ej0ebN28O+ght//j79Omj\n9957T9JP10J+/PFHnXjiiUFlHSg1NTWQ53K5tHXrViUnJ4ecd6jmzlFzNDZnV155pV577TX95z//\n0bBhw1q0HZPZbDaNHj1aRUVFGjx48GE/v88++0zJycnq0KFD4Nrg5s2bG83bz+l06rHHHtMf//hH\nFRUVqUOHDoFfDKGeUWhsv9uyZYvKyspUXFys6dOny+fzye/3KyIiosXXj8ORcSC/36/Kykq53W4t\nXrxYc+Yvn0PFAAADG0lEQVTM0ezZs0POO9p8rlq1SpMnT5bD4ZDf79cbb7zRotyuXbsGXsT17rvv\nBoqjOfOTlpamqqoqbdq0ScOGDZPb7da///3vg/Yvm82mffv2NfqYjqSx58WBSkpKNGvWLDkcDm3e\nvFkffPDBUddt6b5xtG9EPJoD86urq+V0OgO/i4PdX/x+f+CxVVdXq76+XieffLJqamrk9/v1ySef\nHLRuSxh5BN2lSxd5vV7V19cfNHk2m02JiYm64YYbNHbsWPl8PiUnJzfrNPSIESNUVFSkN954Q6ed\ndppiY2Pl9XoP++GcccYZuuiii3T11VerS5cu6ty5c8jjd7vdeuedd/TPf/5Te/fu1ezZs4N+Yh3o\nmmuu0YwZM5Sbm6u9e/dq0qRJ+vrrr8N2ivfQOYqLi5PX6w3pBTH7x3To2Gw2W+Av2MzMzBbNx5G2\nF07hyBwzZoyGDRuml156ScnJyYf9/BITE5WXl6dZs2ape/fu6tatW7PGEx8fr4yMDF177bVKTExU\n7969tX37diUnJx+2zxz672XLlumUU07RRRdddFB+Y/tdSkqKTjjhBI0dO1adO3fWmWeeqZqaGp17\n7rnyer2aN29eyK8B6N+/v2666SY5HI6Q7n+o/ePdsGGDXn31Vfl8Pk2ZMqVFeUeSnp4eODUdFxen\nESNGhJxrs9lUVFSk2bNny+/3KyoqSvfff7+kn+Zn/Pjx+vOf/9xo3vnnn69vvvlGNptNAwYMUEVF\nhU444YTAdjIyMvTII48c8Y/6xp7rjT0vDnT66acrNzdXcXFxOvnkk496yny/luwbweybNptNN998\ns+6+++7A7+L77rtPkZGRIe3jNptNu3fv1q9//Wvt2bNHRUVF2rZtm8aPH6+ePXsedBCWmpqqO+64\nQw899FDQ25H4LG4cJxMnTtTdd9+tXr16He+hWKqmpkZ33nmnnn766eM9FMAo7BtNM/IUN9quvXv3\nasyYMerTp0+bL+fXX39d48aN0+9+97vjPRTAKOwbzcMRNAAABuIIGgAAA1HQAAAYiIIGAMBAFDQA\nAAaioAEAMND/A8NudfT377dBAAAAAElFTkSuQmCC\n",
1517 |       "text/plain": [
1518 |        ""
1519 |       ]
1520 |      },
1521 |      "metadata": {},
1522 |      "output_type": "display_data"
1523 |     }
1524 |    ],
1525 |    "source": [
1526 |     "topfreq=L[:20]\n",
1527 |     "print topfreq\n",
1528 |     "pos = np.arange(len(topfreq))\n",
1529 |     "plt.bar(pos, [e[1] for e in topfreq]);\n",
1530 |     "plt.xticks(pos+0.4, [e[0] for e in topfreq]);"
1531 |    ]
1532 |   }
1533 |  ],
1534 |  "metadata": {
1535 |   "kernelspec": {
1536 |    "display_name": "Python 2",
1537 |    "language": "python",
1538 |    "name": "python2"
1539 |   },
1540 |   "language_info": {
1541 |    "codemirror_mode": {
1542 |     "name": "ipython",
1543 |     "version": 2
1544 |    },
1545 |    "file_extension": ".py",
1546 |    "mimetype": "text/x-python",
1547 |    "name": "python",
1548 |    "nbconvert_exporter": "python",
1549 |    "pygments_lexer": "ipython2",
1550 |    "version": "2.7.10"
1551 |   }
1552 |  },
1553 |  "nbformat": 4,
1554 |  "nbformat_minor": 0
1555 | }
1556 | 


--------------------------------------------------------------------------------
/Lab1-babypython_original.ipynb:
--------------------------------------------------------------------------------
   1 | {
   2 |  "cells": [
   3 |   {
   4 |    "cell_type": "markdown",
   5 |    "metadata": {},
   6 |    "source": [
   7 |     "# Python and Friends\n",
   8 |     "\n",
   9 |     "This is a very quick run-through of some python syntax"
  10 |    ]
  11 |   },
  12 |   {
  13 |    "cell_type": "code",
  14 |    "execution_count": 1,
  15 |    "metadata": {
  16 |     "collapsed": false
  17 |    },
  18 |    "outputs": [],
  19 |    "source": [
  20 |     "# The %... is an iPython thing, and is not part of the Python language.\n",
  21 |     "# In this case we're just telling the plotting library to draw things on\n",
  22 |     "# the notebook, instead of on a separate window.\n",
  23 |     "%matplotlib inline \n",
  24 |     "#this line above prepares IPython notebook for working with matplotlib\n",
  25 |     "\n",
  26 |     "# See all the \"as ...\" contructs? They're just aliasing the package names.\n",
  27 |     "# That way we can call methods like plt.plot() instead of matplotlib.pyplot.plot().\n",
  28 |     "\n",
  29 |     "import numpy as np # imports a fast numerical programming library\n",
  30 |     "import scipy as sp #imports stats functions, amongst other things\n",
  31 |     "import matplotlib as mpl # this actually imports matplotlib\n",
  32 |     "import matplotlib.cm as cm #allows us easy access to colormaps\n",
  33 |     "import matplotlib.pyplot as plt #sets up plotting under plt\n",
  34 |     "import pandas as pd #lets us handle data as dataframes\n",
  35 |     "#sets up pandas table display\n",
  36 |     "pd.set_option('display.width', 500)\n",
  37 |     "pd.set_option('display.max_columns', 100)\n",
  38 |     "pd.set_option('display.notebook_repr_html', True)\n",
  39 |     "import seaborn as sns #sets up styles and gives us more plotting options"
  40 |    ]
  41 |   },
  42 |   {
  43 |    "cell_type": "markdown",
  44 |    "metadata": {},
  45 |    "source": [
  46 |     "##The Python Language\n",
  47 |     "\n",
  48 |     "Lets talk about using Python as a calculator..."
  49 |    ]
  50 |   },
  51 |   {
  52 |    "cell_type": "code",
  53 |    "execution_count": 2,
  54 |    "metadata": {
  55 |     "collapsed": false
  56 |    },
  57 |    "outputs": [
  58 |     {
  59 |      "data": {
  60 |       "text/plain": [
  61 |        "3"
  62 |       ]
  63 |      },
  64 |      "execution_count": 2,
  65 |      "metadata": {},
  66 |      "output_type": "execute_result"
  67 |     }
  68 |    ],
  69 |    "source": [
  70 |     "1+2"
  71 |    ]
  72 |   },
  73 |   {
  74 |    "cell_type": "markdown",
  75 |    "metadata": {},
  76 |    "source": [
  77 |     "Notice integer division and floating-point error below!"
  78 |    ]
  79 |   },
  80 |   {
  81 |    "cell_type": "code",
  82 |    "execution_count": 3,
  83 |    "metadata": {
  84 |     "collapsed": false
  85 |    },
  86 |    "outputs": [
  87 |     {
  88 |      "data": {
  89 |       "text/plain": [
  90 |        "(0, 0.5, 9.600000000000001)"
  91 |       ]
  92 |      },
  93 |      "execution_count": 3,
  94 |      "metadata": {},
  95 |      "output_type": "execute_result"
  96 |     }
  97 |    ],
  98 |    "source": [
  99 |     "1/2,1.0/2.0,3*3.2"
 100 |    ]
 101 |   },
 102 |   {
 103 |    "cell_type": "markdown",
 104 |    "metadata": {},
 105 |    "source": [
 106 |     "Here is how we can print things. Something on the last line by itself is returned as the output value."
 107 |    ]
 108 |   },
 109 |   {
 110 |    "cell_type": "code",
 111 |    "execution_count": 4,
 112 |    "metadata": {
 113 |     "collapsed": false
 114 |    },
 115 |    "outputs": [
 116 |     {
 117 |      "name": "stdout",
 118 |      "output_type": "stream",
 119 |      "text": [
 120 |       "4.0 \n",
 121 |       "1.66666666667\n"
 122 |      ]
 123 |     },
 124 |     {
 125 |      "data": {
 126 |       "text/plain": [
 127 |        "1"
 128 |       ]
 129 |      },
 130 |      "execution_count": 4,
 131 |      "metadata": {},
 132 |      "output_type": "execute_result"
 133 |     }
 134 |    ],
 135 |    "source": [
 136 |     "print 1+3.0,\"\\n\",5/3.0\n",
 137 |     "5/3"
 138 |    ]
 139 |   },
 140 |   {
 141 |    "cell_type": "markdown",
 142 |    "metadata": {},
 143 |    "source": [
 144 |     "We can obtain the type of a variable, and use boolean comparisons tontest these types."
 145 |    ]
 146 |   },
 147 |   {
 148 |    "cell_type": "code",
 149 |    "execution_count": 5,
 150 |    "metadata": {
 151 |     "collapsed": false
 152 |    },
 153 |    "outputs": [
 154 |     {
 155 |      "name": "stdout",
 156 |      "output_type": "stream",
 157 |      "text": [
 158 |       "0.833333333333\n",
 159 |       "\n"
 160 |      ]
 161 |     }
 162 |    ],
 163 |    "source": [
 164 |     "a=5.0/6.0\n",
 165 |     "print(a)\n",
 166 |     "print type(a)"
 167 |    ]
 168 |   },
 169 |   {
 170 |    "cell_type": "code",
 171 |    "execution_count": 6,
 172 |    "metadata": {
 173 |     "collapsed": false
 174 |    },
 175 |    "outputs": [
 176 |     {
 177 |      "data": {
 178 |       "text/plain": [
 179 |        "True"
 180 |       ]
 181 |      },
 182 |      "execution_count": 6,
 183 |      "metadata": {},
 184 |      "output_type": "execute_result"
 185 |     }
 186 |    ],
 187 |    "source": [
 188 |     "import types\n",
 189 |     "type(a)==types.FloatType"
 190 |    ]
 191 |   },
 192 |   {
 193 |    "cell_type": "code",
 194 |    "execution_count": 7,
 195 |    "metadata": {
 196 |     "collapsed": false
 197 |    },
 198 |    "outputs": [
 199 |     {
 200 |      "data": {
 201 |       "text/plain": [
 202 |        "False"
 203 |       ]
 204 |      },
 205 |      "execution_count": 7,
 206 |      "metadata": {},
 207 |      "output_type": "execute_result"
 208 |     }
 209 |    ],
 210 |    "source": [
 211 |     "type(a)==types.IntType"
 212 |    ]
 213 |   },
 214 |   {
 215 |    "cell_type": "markdown",
 216 |    "metadata": {},
 217 |    "source": [
 218 |     "## Python and Iteration (and files)\n",
 219 |     "\n",
 220 |     "In working with python I always remember: a python is a duck.\n",
 221 |     "\n",
 222 |     "What I mean is, python has a certain way of doing things. For example lets call one of these ways listiness. Listiness works on lists, dictionaries, files, and a general notion of something called an iterator.\n",
 223 |     "\n",
 224 |     "But first, lets introduce the notion of a comprehension. Its a way of constructing a list"
 225 |    ]
 226 |   },
 227 |   {
 228 |    "cell_type": "code",
 229 |    "execution_count": 8,
 230 |    "metadata": {
 231 |     "collapsed": false
 232 |    },
 233 |    "outputs": [
 234 |     {
 235 |      "data": {
 236 |       "text/plain": [
 237 |        "[1, 4, 9, 16, 25]"
 238 |       ]
 239 |      },
 240 |      "execution_count": 8,
 241 |      "metadata": {},
 242 |      "output_type": "execute_result"
 243 |     }
 244 |    ],
 245 |    "source": [
 246 |     "alist=[1,2,3,4,5]\n",
 247 |     "asquaredlist=[i*i for i in alist]\n",
 248 |     "asquaredlist"
 249 |    ]
 250 |   },
 251 |   {
 252 |    "cell_type": "markdown",
 253 |    "metadata": {},
 254 |    "source": [
 255 |     "Python has some nifty functions like `enumerate` and `zip`. The former gives a list of tuples with each tuple of the form `(index, value)`, while the latter takes elements from each list and outs them together into a tuple, thus creating a list of tuples. The first is a duck, but the second isnt."
 256 |    ]
 257 |   },
 258 |   {
 259 |    "cell_type": "code",
 260 |    "execution_count": 9,
 261 |    "metadata": {
 262 |     "collapsed": false
 263 |    },
 264 |    "outputs": [
 265 |     {
 266 |      "data": {
 267 |       "text/plain": [
 268 |        "(, [(1, 1), (2, 4), (3, 9), (4, 16), (5, 25)])"
 269 |       ]
 270 |      },
 271 |      "execution_count": 9,
 272 |      "metadata": {},
 273 |      "output_type": "execute_result"
 274 |     }
 275 |    ],
 276 |    "source": [
 277 |     "enumerate(asquaredlist),zip(alist, asquaredlist)"
 278 |    ]
 279 |   },
 280 |   {
 281 |    "cell_type": "markdown",
 282 |    "metadata": {},
 283 |    "source": [
 284 |     "Someone realized that design flaw and created izip."
 285 |    ]
 286 |   },
 287 |   {
 288 |    "cell_type": "code",
 289 |    "execution_count": 10,
 290 |    "metadata": {
 291 |     "collapsed": false
 292 |    },
 293 |    "outputs": [
 294 |     {
 295 |      "data": {
 296 |       "text/plain": [
 297 |        ""
 298 |       ]
 299 |      },
 300 |      "execution_count": 10,
 301 |      "metadata": {},
 302 |      "output_type": "execute_result"
 303 |     }
 304 |    ],
 305 |    "source": [
 306 |     "from itertools import izip\n",
 307 |     "izip(alist, asquaredlist)"
 308 |    ]
 309 |   },
 310 |   {
 311 |    "cell_type": "code",
 312 |    "execution_count": 11,
 313 |    "metadata": {
 314 |     "collapsed": false
 315 |    },
 316 |    "outputs": [
 317 |     {
 318 |      "name": "stdout",
 319 |      "output_type": "stream",
 320 |      "text": [
 321 |       "\n"
 322 |      ]
 323 |     }
 324 |    ],
 325 |    "source": [
 326 |     "print enumerate(asquaredlist)"
 327 |    ]
 328 |   },
 329 |   {
 330 |    "cell_type": "code",
 331 |    "execution_count": 12,
 332 |    "metadata": {
 333 |     "collapsed": false
 334 |    },
 335 |    "outputs": [
 336 |     {
 337 |      "data": {
 338 |       "text/plain": [
 339 |        "[(0, 1), (1, 4), (2, 9), (3, 16), (4, 25)]"
 340 |       ]
 341 |      },
 342 |      "execution_count": 12,
 343 |      "metadata": {},
 344 |      "output_type": "execute_result"
 345 |     }
 346 |    ],
 347 |    "source": [
 348 |     "[k for k in enumerate(asquaredlist)]"
 349 |    ]
 350 |   },
 351 |   {
 352 |    "cell_type": "markdown",
 353 |    "metadata": {},
 354 |    "source": [
 355 |     "Open files behave like lists too! Here we get each line in the file and find its length, using the comprehension syntax to put these lengths into a big list."
 356 |    ]
 357 |   },
 358 |   {
 359 |    "cell_type": "code",
 360 |    "execution_count": 13,
 361 |    "metadata": {
 362 |     "collapsed": false
 363 |    },
 364 |    "outputs": [
 365 |     {
 366 |      "name": "stdout",
 367 |      "output_type": "stream",
 368 |      "text": [
 369 |       "[9, 27, 2, 24, 2, 2, 2, 2, 22, 2, 28, 60, 29, 28, 27, 22, 22, 24, 25, 18, 24, 11, 21, 20, 22, 32, 10, 28, 31, 12, 22, 27, 2, 51, 32, 2, 67, 13, 2, 18, 2, 2, 2, 8, 2, 50, 2, 49, 2, 6, 14, 2, 7, 45, 2, 6, 21, 2, 7, 11, 2, 6, 5, 2, 7, 41, 2, 6, 53, 2, 7, 48, 25, 2, 6, 27, 2, 7, 23, 2, 6, 19, 39, 46, 2, 7, 48, 2, 32, 2, 6, 25, 2, 6, 27, 2, 7, 22, 2, 6, 30, 24, 2, 7, 24, 22, 2, 9, 2, 6, 18, 2, 6, 6, 25, 2, 6, 17, 2, 6, 45, 2, 6, 47, 2, 6, 22, 2, 6, 36, 42, 48, 38, 45, 37, 42, 2, 6, 32, 2, 6, 18, 41, 42, 31, 2, 6, 20, 41, 2, 6, 20, 51, 51, 43, 30, 2, 6, 51, 2, 23, 2, 6, 48, 2, 6, 43, 2, 6, 47, 2, 6, 49, 2, 6, 23, 2, 6, 23, 2, 6, 50, 42, 40, 54, 2, 6, 17, 2, 6, 22, 2, 6, 42, 2, 15, 2, 6, 33, 2, 6, 46, 42, 22, 2, 6, 41, 38, 19, 2, 6, 26, 2, 6, 25, 36, 40, 45, 42, 15, 2, 6, 48, 47, 2, 6, 48, 44, 48, 2, 6, 49, 47, 43, 43, 41, 50, 43, 46, 50, 30, 2, 6, 13, 47, 42, 44, 45, 53, 53, 53, 36, 50, 45, 39, 43, 35, 50, 39, 49, 36, 47, 41, 39, 48, 42, 39, 46, 45, 41, 50, 44, 2, 6, 37, 47, 49, 45, 2, 6, 41, 43, 41, 51, 45, 50, 43, 47, 43, 48, 42, 39, 45, 38, 46, 2, 19, 2, 53, 42, 14, 40, 44, 14, 42, 40, 11, 39, 41, 53, 19, 53, 2, 6, 40, 2, 6, 27, 2, 6, 12, 2, 6, 12, 2, 6, 12, 2, 15, 2, 38, 35, 38, 39, 2, 6, 44, 2, 6, 42, 38, 44, 48, 43, 42, 40, 41, 37, 2, 6, 38, 46, 44, 45, 49, 51, 48, 42, 2, 6, 45, 45, 47, 42, 42, 39, 45, 47, 44, 2, 6, 45, 44, 2, 11, 2, 2, 2, 52, 2, 63, 35, 2, 7, 47, 46, 52, 38, 47, 42, 41, 47, 47, 43, 42, 52, 45, 42, 45, 46, 47, 39, 46, 44, 46, 47, 40, 44, 49, 47, 47, 41, 43, 44, 46, 46, 43, 42, 45, 41, 48, 34, 49, 2, 16, 47, 2, 7, 41, 2, 35, 2, 45, 47, 41, 54, 45, 43, 42, 46, 34, 2, 7, 16, 44, 49, 37, 42, 50, 49, 2, 7, 51, 2, 6, 47, 37, 41, 41, 2, 7, 45, 45, 41, 2, 6, 54, 2, 7, 46, 2, 6, 44, 2, 8, 43, 50, 38, 40, 53, 37, 2, 6, 26, 2, 8, 11, 39, 2, 6, 45, 44, 38, 41, 40, 41, 49, 48, 45, 44, 47, 2, 7, 52, 47, 48, 53, 37, 43, 38, 46, 43, 40, 41, 44, 40, 43, 48, 46, 43, 48, 48, 48, 40, 45, 43, 35, 46, 41, 40, 38, 39, 43, 45, 2, 8, 46, 49, 2, 6, 41, 2, 7, 38, 41, 43, 45, 45, 48, 52, 41, 2, 26, 2, 6, 45, 38, 39, 49, 42, 40, 43, 53, 49, 50, 41, 46, 46, 47, 45, 38, 47, 55, 45, 47, 46, 48, 54, 49, 37, 44, 43, 46, 43, 40, 49, 2, 43, 2, 6, 24, 2, 6, 28, 34, 2, 6, 48, 2, 6, 54, 47, 12, 2, 6, 17, 2, 6, 47, 47, 2, 6, 37, 2, 6, 37, 40, 39, 45, 38, 47, 2, 6, 47, 2, 6, 43, 44, 2, 6, 41, 2, 6, 50, 47, 42, 41, 39, 2, 6, 17, 2, 6, 28, 2, 6, 39, 2, 6, 40, 39, 2, 6, 41, 2, 6, 10, 2, 6, 32, 2, 6, 21, 2, 6, 35, 41, 38, 21, 2, 6, 29, 2, 6, 42, 40, 43, 51, 35, 43, 49, 45, 55, 39, 46, 38, 49, 45, 50, 43, 32, 2, 6, 21, 2, 6, 46, 2, 6, 26, 2, 6, 17, 45, 39, 43, 43, 43, 30, 2, 6, 20, 2, 6, 44, 43, 24, 2, 6, 45, 30, 2, 15, 17, 2, 6, 17, 2, 7, 17, 2, 6, 18, 2, 7, 29, 2, 6, 28, 2, 6, 41, 2, 6, 29, 2, 6, 45, 2, 6, 14, 2, 6, 17, 2, 6, 30, 2, 6, 18, 2, 6, 27, 2, 6, 32, 2, 6, 39, 2, 6, 53, 2, 15, 17, 2, 6, 19, 2, 6, 30, 2, 6, 40, 19, 2, 6, 24, 30, 2, 6, 20, 2, 6, 40, 50, 43, 44, 42, 41, 42, 46, 46, 17, 2, 6, 26, 2, 6, 39, 2, 44, 2, 46, 52, 53, 53, 2, 9, 2, 2, 2, 40, 2, 30, 2, 7, 40, 40, 40, 27, 2, 6, 20, 2, 7, 45, 40, 40, 45, 41, 10, 2, 6, 17, 2, 7, 19, 43, 46, 41, 46, 42, 44, 49, 41, 37, 46, 44, 48, 42, 55, 42, 39, 47, 45, 46, 45, 50, 32, 44, 45, 39, 38, 39, 46, 44, 44, 41, 42, 41, 48, 2, 6, 45, 48, 40, 45, 47, 47, 29, 2, 7, 17, 45, 2, 19, 2, 38, 38, 2, 6, 47, 45, 56, 2, 38, 2, 38, 51, 41, 43, 52, 49, 45, 48, 42, 45, 46, 52, 40, 46, 40, 49, 45, 37, 44, 44, 45, 43, 42, 44, 2, 7, 42, 2, 6, 47, 2, 7, 38, 26, 2, 6, 27, 44, 2, 7, 11, 2, 9, 2, 6, 42, 2, 6, 52, 2, 6, 24, 39, 45, 53, 37, 46, 43, 45, 44, 2, 6, 45, 25, 2, 6, 47, 41, 47, 2, 6, 46, 2, 6, 47, 49, 54, 48, 45, 2, 6, 42, 24, 2, 6, 44, 2, 6, 52, 42, 2, 6, 45, 45, 48, 48, 45, 44, 47, 40, 44, 43, 38, 41, 50, 47, 39, 44, 43, 51, 40, 48, 42, 2, 6, 24, 2, 11, 2, 2, 2, 25, 2, 41, 2, 6, 42, 2, 6, 35, 2, 6, 16, 2, 6, 29, 2, 6, 19, 2, 6, 52, 43, 2, 57, 2, 31, 2, 6, 50, 52, 49, 43, 28, 2, 6, 17, 2, 6, 18, 43, 41, 50, 39, 47, 50, 42, 52, 39, 37, 48, 50, 42, 39, 50, 46, 50, 43, 45, 48, 35, 46, 46, 42, 21, 2, 6, 26, 2, 16, 2, 6, 44, 46, 55, 38, 42, 51, 41, 41, 44, 48, 39, 41, 44, 49, 43, 46, 38, 48, 49, 2, 25, 2, 6, 36, 37, 15, 2, 6, 33, 40, 24, 2, 6, 18, 2, 6, 43, 2, 6, 18, 2, 6, 31, 38, 42, 35, 43, 2, 6, 49, 40, 42, 43, 49, 41, 42, 39, 38, 28, 2, 6, 22, 26, 2, 6, 28, 2, 6, 22, 2, 6, 29, 2, 6, 20, 42, 40, 2, 18, 2, 45, 2, 28, 2, 53, 40, 2, 28, 2, 6, 38, 2, 6, 46, 2, 6, 44, 2, 6, 46, 2, 6, 24, 2, 6, 24, 2, 11, 2, 2, 2, 44, 2, 27, 2, 6, 55, 2, 8, 10, 2, 6, 9, 2, 8, 25, 44, 24, 2, 6, 19, 2, 8, 43, 25, 2, 6, 28, 2, 8, 47, 2, 6, 7, 2, 8, 27, 46, 44, 48, 49, 41, 43, 51, 58, 41, 42, 41, 37, 53, 43, 2, 6, 8, 2, 8, 45, 2, 6, 9, 2, 8, 41, 45, 2, 6, 49, 40, 26, 2, 8, 18, 47, 42, 51, 46, 49, 36, 44, 46, 22, 2, 6, 22, 13, 2, 8, 45, 54, 45, 41, 45, 41, 41, 45, 43, 45, 19, 40, 48, 44, 37, 22, 45, 47, 36, 38, 41, 40, 39, 40, 48, 43, 41, 43, 47, 41, 48, 21, 44, 50, 41, 37, 43, 39, 42, 43, 37, 39, 40, 47, 48, 46, 49, 42, 41, 36, 2, 9, 2, 6, 47, 51, 43, 41, 48, 42, 34, 42, 51, 42, 42, 41, 46, 26, 46, 39, 50, 47, 2, 12, 2, 43, 36, 17, 2, 6, 31, 2, 6, 26, 2, 6, 30, 2, 6, 11, 2, 6, 34, 2, 6, 39, 2, 32, 2, 6, 26, 2, 6, 21, 2, 6, 15, 2, 6, 24, 2, 6, 23, 2, 6, 28, 2, 6, 17, 2, 6, 55, 23, 2, 15, 25, 2, 6, 49, 27, 2, 6, 52, 18, 2, 6, 35, 43, 45, 54, 41, 43, 25, 2, 6, 49, 2, 6, 38, 23, 2, 6, 30, 2, 6, 47, 52, 46, 45, 49, 45, 27, 2, 6, 30, 2, 6, 47, 2, 15, 23, 2, 6, 19, 2, 6, 11, 17, 2, 6, 27, 2, 6, 16, 2, 6, 34, 2, 6, 32, 2, 8, 19, 2, 6, 58, 52, 19, 2, 6, 28, 2, 6, 44, 20, 2, 8, 19, 2, 6, 47, 25, 41, 45, 20, 2, 8, 19, 2, 6, 55, 51, 2, 6, 48, 2, 6, 46, 53, 40, 13, 44, 44, 45, 35, 49, 48, 44, 60, 62, 39, 48, 48, 8, 2, 8, 19, 2, 6, 47, 42, 37, 51, 53, 46, 44, 41, 31, 2, 11, 2, 2, 2, 9, 2, 38, 2, 32, 2, 6, 48, 2, 6, 18, 2, 6, 48, 39, 19, 2, 6, 27, 2, 6, 50, 46, 52, 45, 46, 48, 45, 53, 46, 47, 2, 6, 25, 2, 6, 50, 40, 43, 48, 42, 46, 40, 23, 2, 6, 21, 2, 6, 50, 31, 2, 6, 36, 2, 6, 48, 42, 34, 59, 43, 41, 36, 21, 2, 6, 22, 2, 6, 31, 2, 6, 14, 20, 2, 6, 30, 41, 43, 51, 11, 46, 44, 45, 41, 50, 41, 21, 2, 6, 21, 2, 6, 67, 64, 2, 6, 56, 13, 2, 6, 44, 50, 38, 56, 49, 45, 43, 39, 14, 50, 40, 42, 38, 38, 46, 2, 6, 18, 2, 6, 32, 2, 6, 15, 2, 6, 38, 2, 6, 19, 2, 6, 28, 2, 6, 16, 2, 6, 11, 2, 18, 2, 18, 2, 38, 2, 6, 43, 2, 6, 32, 2, 6, 41, 46, 45, 42, 51, 39, 38, 43, 2, 6, 19, 2, 6, 25, 25, 2, 6, 15, 2, 6, 44, 44, 45, 37, 41, 41, 48, 42, 40, 46, 45, 45, 46, 43, 2, 6, 44, 35, 40, 47, 36, 46, 50, 2, 6, 44, 36, 19, 2, 6, 25, 47, 51, 51, 34, 42, 38, 46, 57, 45, 2, 11, 2, 2, 2, 33, 2, 58, 2, 7, 45, 44, 41, 45, 43, 43, 43, 54, 44, 39, 51, 51, 48, 40, 45, 41, 50, 39, 2, 8, 45, 44, 48, 41, 40, 40, 43, 31, 2, 6, 21, 47, 44, 19, 2, 7, 15, 47, 41, 18, 2, 7, 46, 2, 8, 46, 38, 44, 44, 2, 7, 45, 30, 2, 8, 11, 2, 58, 2, 19, 2, 6, 44, 24, 2, 7, 47, 2, 6, 45, 36, 41, 45, 39, 43, 36, 2, 7, 43, 2, 6, 43, 49, 2, 7, 46, 2, 18, 2, 44, 50, 2, 8, 40, 48, 2, 7, 26, 2, 49, 2, 27, 47, 2, 7, 44, 41, 44, 41, 41, 50, 42, 47, 43, 44, 39, 49, 40, 48, 46, 42, 41, 18, 45, 45, 41, 26, 2, 7, 19, 45, 39, 50, 49, 20, 2, 35, 2, 6, 32, 38, 39, 51, 49, 46, 51, 42, 44, 43, 18, 2, 8, 29, 2, 6, 37, 49, 44, 41, 44, 44, 42, 43, 42, 10, 48, 39, 46, 10, 60, 13, 61, 35, 10, 44, 2, 8, 31, 2, 6, 46, 10, 35, 36, 30, 30, 63, 67, 12, 67, 15, 49, 39, 48, 24, 2, 7, 18, 20, 2, 6, 26, 2, 7, 38, 2, 6, 50, 46, 42, 47, 44, 41, 45, 45, 49, 43, 46, 50, 47, 41, 47, 44, 40, 44, 49, 40, 22, 2, 7, 25, 2, 8, 25, 2, 6, 52, 40, 27, 2, 7, 18, 2, 6, 44, 36, 39, 47, 20, 2, 7, 28, 2, 6, 48, 20, 2, 8, 20, 2, 6, 47, 36, 41, 43, 37, 30, 2, 7, 17, 2, 8, 53, 2, 6, 35, 46, 2, 39, 2, 26, 2, 31, 2, 6, 20, 2, 6, 26, 2, 6, 38, 2, 6, 17, 2, 6, 40, 2, 6, 18, 2, 6, 61, 29, 2, 6, 28, 2, 6, 65, 32, 2, 6, 18, 2, 6, 64, 52, 2, 6, 67, 64, 65, 65, 16, 2, 6, 22, 2, 6, 30, 2, 6, 14, 2, 6, 44, 2, 6, 63, 61, 61, 65, 67, 62, 64, 2, 6, 64, 40, 2, 6, 16, 2, 6, 65, 64, 64, 67, 67, 18, 2, 6, 57, 67, 7, 2, 6, 25, 2, 6, 26, 2, 39, 2, 6, 46, 2, 6, 35, 2, 18, 2, 7, 19, 2, 6, 20, 2, 6, 61, 41, 2, 6, 43, 2, 7, 38, 46, 2, 6, 28, 2, 6, 19, 2, 6, 56, 10, 2, 7, 25, 2, 6, 56, 28, 2, 6, 51, 2, 6, 58, 62, 64, 9, 2, 7, 18, 2, 6, 21, 2, 6, 24, 2, 6, 60, 43, 2, 6, 27, 2, 6, 62, 56, 2, 6, 65, 7, 2, 6, 61, 61, 2, 7, 63, 48, 2, 6, 33, 2, 6, 64, 30, 2, 6, 64, 64, 23, 2, 17, 22, 2, 6, 57, 62, 65, 23, 2, 6, 43, 2, 6, 62, 66, 58, 64, 2, 7, 30, 2, 6, 59, 67, 65, 20, 2, 6, 23, 2, 6, 63, 59, 64, 66, 38, 2, 6, 34, 2, 6, 65, 10, 2, 7, 28, 2, 6, 60, 60, 66, 64, 64, 67, 66, 64, 65, 60, 62, 64, 67, 66, 53, 2, 6, 50, 2, 6, 60, 2, 6, 59, 65, 62, 2, 6, 61, 67, 65, 63, 63, 63, 7, 2, 6, 56, 25, 2, 6, 54, 46, 2, 6, 57, 13, 2, 6, 61, 29, 2, 6, 27, 2, 6, 35, 2, 6, 62, 66, 65, 67, 65, 27, 2, 6, 58, 63, 57, 67, 66, 31, 2, 6, 64, 62, 66, 32, 2, 6, 16, 2, 7, 50, 2, 6, 28, 2, 6, 55, 2, 6, 62, 65, 67, 67, 31, 2, 32, 2, 7, 24, 2, 6, 63, 64, 63, 60, 64, 31, 2, 7, 24, 2, 6, 61, 29, 2, 19, 2, 6, 30, 2, 6, 67, 66, 2, 6, 64, 23, 2, 6, 67, 53, 2, 6, 35, 2, 6, 64, 9, 2, 6, 38, 2, 6, 13, 2, 6, 19, 2, 6, 36, 2, 6, 59, 59, 66, 64, 67, 15, 2, 6, 58, 2, 6, 32, 2, 6, 7, 37, 38, 2, 2, 6, 32, 2, 6, 38, 2, 6, 60, 20, 2, 6, 24, 2, 6, 30, 2, 6, 7, 26, 21, 45, 65, 28, 2, 31, 2, 64, 62, 60, 61, 63, 62, 67, 60, 64, 51, 2, 9, 23, 2, 6, 63, 65, 66, 67, 67, 64, 64, 61, 62, 67, 67, 64, 61, 2, 49, 2, 43, 2, 46, 49, 48, 53, 44, 44, 53, 50, 45, 54, 44, 51, 32, 2, 18, 2, 6, 60, 13, 2, 9, 23, 53, 48, 43, 51, 50, 53, 48, 49, 52, 42, 51, 44, 48, 17, 45, 52, 49, 48, 52, 44, 44, 47, 51, 26, 52, 43, 53, 53, 29, 2, 6, 19, 2, 6, 64, 65, 12, 2, 9, 49, 2, 6, 21, 2, 6, 38, 2, 9, 53, 46, 49, 45, 49, 53, 59, 49, 46, 51, 50, 49, 54, 29, 2, 6, 64, 27, 2, 6, 62, 62, 67, 65, 51, 2, 6, 53, 2, 6, 53, 64, 65, 28, 2, 6, 13, 2, 6, 51, 2, 55, 2, 60, 11, 2, 9, 14, 2, 6, 60, 66, 29, 2, 9, 14, 2, 6, 58, 2, 22, 2, 61, 37, 2, 6, 15, 2, 40, 2, 6, 24, 17, 41, 44, 42, 44, 45, 45, 48, 49, 13, 40, 48, 43, 50, 48, 42, 43, 38, 8, 40, 45, 41, 40, 42, 46, 46, 55, 48, 46, 40, 40, 43, 49, 56, 15, 44, 44, 44, 48, 38, 13, 49, 43, 39, 43, 42, 50, 53, 45, 44, 47, 47, 44, 46, 41, 43, 41, 48, 48, 2, 9, 2, 2, 2, 2, 10, 2, 32, 2, 57, 16, 2, 7, 43, 45, 42, 38, 2, 6, 46, 48, 2, 7, 43, 41, 47, 20, 2, 8, 26, 2, 6, 24, 2, 7, 43, 2, 6, 43, 25, 2, 8, 19, 17, 2, 6, 44, 50, 41, 42, 42, 32, 2, 6, 17, 47, 29, 2, 7, 48, 28, 42, 45, 2, 6, 20, 2, 40, 2, 7, 31, 45, 42, 18, 43, 48, 42, 38, 42, 27, 2, 8, 21, 39, 44, 52, 41, 23, 2, 6, 23, 2, 15, 2, 6, 51, 61, 42, 50, 52, 35, 20, 2, 7, 28, 55, 51, 45, 42, 17, 2, 6, 45, 2, 29, 2, 17, 2, 6, 47, 43, 45, 44, 49, 39, 48, 45, 45, 53, 50, 45, 41, 38, 50, 51, 46, 41, 43, 40, 51, 40, 48, 44, 42, 45, 41, 46, 39, 49, 43, 45, 45, 42, 28, 2, 6, 15, 43, 2, 6, 39, 2, 6, 39, 40, 31, 2, 6, 12, 25, 2, 6, 48, 49, 51, 41, 47, 17, 2, 6, 25, 2, 6, 10, 2, 6, 15, 2, 6, 27, 2, 6, 62, 27, 2, 6, 64, 2, 6, 58, 65, 66, 55, 2, 6, 42, 2, 6, 55, 64, 6, 2, 6, 26, 2, 6, 57, 65, 67, 66, 63, 67, 66, 60, 9, 2, 6, 19, 2, 6, 59, 39, 2, 6, 33, 2, 6, 65, 66, 64, 63, 63, 11, 2, 6, 33, 2, 6, 59, 67, 66, 67, 63, 66, 29, 2, 9, 2, 6, 42, 59, 44, 45, 52, 43, 42, 47, 50, 48, 37, 48, 2, 31, 2, 7, 44, 52, 53, 42, 43, 44, 31, 51, 42, 42, 36, 45, 48, 47, 2, 6, 40, 42, 48, 45, 46, 41, 44, 47, 47, 47, 43, 31, 2, 7, 17, 46, 2, 11, 2, 2, 2, 33, 2, 37, 2, 6, 58, 64, 65, 60, 62, 52, 65, 67, 67, 65, 67, 52, 2, 11, 24, 2, 6, 62, 66, 63, 66, 63, 64, 64, 66, 60, 62, 65, 65, 59, 64, 60, 64, 25, 2, 11, 58, 2, 6, 62, 63, 63, 64, 65, 64, 17, 2, 19, 2, 50, 2, 58, 2, 6, 40, 2, 6, 29, 2, 18, 2, 35, 2, 16, 19, 2, 25, 2, 6, 20, 2, 18, 2, 6, 36, 2, 6, 38, 39, 2, 6, 20, 2, 6, 30, 44, 45, 60, 46, 43, 50, 48, 44, 50, 49, 42, 52, 49, 47, 49, 50, 47, 46, 43, 46, 47, 47, 40, 43, 39, 41, 33, 44, 41, 45, 28, 2, 6, 16, 52, 44, 2, 6, 46, 18, 2, 66, 41, 2, 7, 30, 2, 6, 62, 45, 2, 7, 62, 7, 2, 6, 67, 21, 2, 6, 54, 2, 6, 21, 2, 6, 64, 12, 2, 6, 65, 20, 2, 6, 44, 2, 8, 41, 2, 6, 48, 2, 6, 41, 2, 6, 32, 33, 2, 6, 14, 2, 6, 32, 2, 6, 14, 2, 6, 39, 2, 6, 27, 2, 6, 51, 2, 6, 19, 2, 6, 10, 2, 6, 25, 2, 6, 9, 2, 6, 14, 2, 6, 60, 65, 22, 2, 6, 38, 2, 6, 62, 66, 66, 67, 62, 57, 2, 41, 2, 62, 60, 59, 57, 63, 66, 66, 61, 64, 67, 43, 2, 11, 2, 6, 27, 2, 6, 53, 2, 6, 52, 2, 19, 2, 6, 64, 19, 2, 6, 39, 2, 6, 61, 50, 2, 6, 53, 2, 6, 33, 36, 35, 2, 6, 44, 2, 6, 22, 2, 6, 18, 2, 29, 2, 10, 49, 47, 44, 50, 49, 39, 2, 11, 39, 44, 42, 47, 46, 43, 43, 36, 49, 41, 52, 56, 2, 10, 50, 48, 48, 42, 27, 2, 11, 23, 47, 38, 47, 2, 6, 30, 2, 11, 41, 48, 38, 39, 2, 10, 44, 40, 37, 38, 51, 40, 36, 45, 42, 44, 37, 46, 48, 47, 49, 54, 43, 50, 51, 45, 41, 46, 43, 33, 38, 40, 40, 52, 43, 51, 2, 11, 46, 46, 40, 42, 43, 46, 47, 35, 2, 6, 43, 2, 10, 49, 48, 29, 11, 2, 11, 23, 44, 2, 9, 2, 6, 32, 2, 8, 39, 2, 6, 30, 2, 7, 56, 2, 6, 61, 8, 2, 7, 28, 2, 6, 58, 63, 65, 61, 66, 14, 2, 19, 2, 43, 2, 6, 33, 2, 6, 61, 23, 2, 6, 38, 2, 6, 51, 2, 6, 26, 2, 6, 62, 64, 22, 2, 6, 58, 46, 49, 52, 37, 38, 2, 45, 2, 6, 64, 62, 66, 2, 6, 17, 2, 6, 33, 2, 8, 20, 2, 6, 21, 2, 7, 28, 2, 6, 25, 2, 38, 2, 6, 40, 30, 48, 32, 66, 62, 60, 2, 6, 15, 2, 6, 22, 38, 32, 41, 28, 2, 6, 24, 2, 6, 59, 24, 2, 6, 21, 2, 6, 35, 2, 6, 27, 2, 6, 51, 41, 45, 19, 2, 39, 2, 7, 45, 2, 6, 23, 2, 7, 17, 2, 6, 23, 2, 7, 48, 2, 6, 18, 2, 7, 34, 2, 6, 63, 62, 34, 2, 7, 61, 31, 2, 6, 29, 2, 7, 61, 22, 2, 6, 18, 2, 7, 61, 65, 62, 34, 2, 6, 16, 2, 7, 16, 2, 6, 64, 65, 65, 8, 2, 6, 57, 27, 2, 6, 65, 50, 2, 6, 64, 2, 6, 60, 24, 2, 6, 32, 2, 6, 51, 2, 6, 64, 63, 14, 2, 6, 26, 2, 6, 62, 33, 2, 6, 64, 8, 2, 41, 2, 67, 66, 14, 2, 7, 63, 2, 6, 62, 2, 7, 20, 2, 6, 13, 2, 7, 23, 2, 6, 19, 2, 7, 34, 2, 6, 56, 63, 63, 2, 7, 59, 21, 2, 6, 61, 64, 63, 64, 63, 65, 65, 26, 2, 19, 2, 21, 2, 6, 57, 2, 6, 60, 2, 6, 44, 2, 6, 31, 2, 6, 29, 2, 6, 18, 2, 6, 20, 2, 6, 63, 41, 2, 6, 16, 2, 9, 2, 6, 27, 2, 18, 2, 22, 2, 41, 2, 43, 53, 55, 40, 51, 44, 41, 33, 44, 45, 39, 45, 2, 9, 2, 2, 2, 34, 2, 46, 2, 7, 44, 50, 44, 41, 40, 39, 22, 2, 7, 28, 36, 37, 39, 2, 6, 40, 47, 45, 45, 41, 43, 46, 43, 49, 50, 42, 42, 46, 2, 7, 45, 41, 33, 2, 15, 19, 2, 25, 2, 19, 2, 6, 45, 37, 56, 43, 50, 50, 50, 39, 27, 2, 7, 23, 2, 18, 2, 45, 43, 38, 41, 45, 43, 45, 44, 50, 47, 48, 40, 48, 40, 44, 47, 49, 44, 48, 44, 45, 41, 45, 43, 42, 47, 49, 47, 45, 43, 41, 43, 44, 45, 57, 41, 18, 2, 23, 2, 17, 2, 6, 43, 47, 47, 42, 44, 12, 42, 43, 51, 50, 48, 48, 41, 46, 5, 46, 42, 43, 40, 41, 51, 46, 44, 43, 2, 9, 2, 32, 2, 7, 44, 44, 2, 9, 2, 2, 2, 39, 2, 29, 2, 6, 50, 55, 53, 47, 30, 2, 6, 35, 2, 8, 19, 44, 2, 35, 2, 17, 2, 6, 33, 2, 8, 45, 2, 6, 43, 2, 8, 45, 2, 6, 44, 2, 8, 23, 2, 6, 24, 2, 8, 21, 2, 6, 26, 51, 49, 2, 8, 50, 2, 6, 52, 38, 43, 2, 8, 47, 17, 2, 6, 39, 2, 6, 26, 25, 2, 35, 2, 6, 26, 2, 19, 2, 8, 28, 2, 6, 34, 2, 25, 2, 8, 41, 2, 6, 45, 44, 2, 8, 17, 2, 6, 28, 48, 16, 47, 47, 52, 46, 36, 40, 45, 2, 8, 51, 30, 2, 6, 13, 44, 44, 45, 47, 43, 40, 41, 47, 39, 44, 29, 2, 8, 18, 48, 2, 6, 45, 46, 43, 46, 44, 35, 39, 35, 43, 39, 52, 44, 48, 48, 45, 42, 48, 48, 54, 53, 42, 44, 41, 49, 46, 46, 48, 40, 20, 47, 43, 40, 45, 46, 43, 26, 2, 8, 26, 43, 46, 32, 2, 6, 18, 39, 48, 23, 2, 8, 25, 46, 24, 2, 6, 27, 46, 42, 40, 45, 27, 2, 8, 10, 2, 6, 33, 2, 16, 2, 44, 56, 2, 8, 17, 2, 6, 42, 46, 45, 9, 2, 8, 32, 44, 42, 46, 46, 23, 2, 6, 27, 2, 8, 26, 39, 48, 46, 45, 45, 42, 42, 46, 2, 6, 46, 52, 48, 43, 42, 51, 2, 8, 28, 2, 6, 27, 2, 8, 40, 2, 6, 27, 2, 8, 28, 2, 6, 47, 38, 50, 2, 15, 2, 8, 41, 32, 21, 2, 6, 10, 49, 49, 44, 46, 47, 46, 48, 47, 44, 45, 44, 45, 49, 41, 40, 45, 2, 8, 46, 2, 6, 38, 41, 45, 38, 46, 41, 42, 37, 41, 40, 45, 48, 45, 47, 41, 47, 25, 45, 43, 44, 41, 47, 35, 46, 27, 2, 8, 18, 2, 6, 43, 44, 49, 43, 51, 40, 39, 49, 48, 42, 46, 38, 38, 46, 41, 31, 2, 8, 46, 47, 28, 2, 6, 35, 2, 8, 8, 37, 2, 6, 53, 46, 47, 41, 40, 49, 45, 48, 46, 32, 46, 46, 49, 42, 46, 21, 2, 52, 2, 2, 2, 9, 2, 32, 2, 52, 2, 7, 54, 50, 20, 2, 8, 41, 2, 48, 2, 46, 2, 7, 34, 2, 8, 44, 43, 42, 45, 42, 26, 2, 7, 15, 44, 40, 39, 47, 41, 54, 46, 44, 40, 40, 45, 2, 8, 40, 43, 33, 47, 2, 7, 24, 45, 48, 40, 49, 2, 42, 2, 50, 40, 51, 49, 45, 2, 40, 2, 51, 43, 47, 42, 38, 51, 43, 40, 2, 11, 2, 39, 2, 17, 2, 6, 16, 2, 16, 32, 2, 6, 53, 2, 39, 2, 6, 50, 2, 6, 44, 2, 6, 49, 28, 2, 6, 20, 2, 6, 15, 2, 6, 64, 67, 12, 2, 6, 36, 2, 6, 61, 64, 64, 66, 65, 8, 2, 6, 32, 2, 6, 60, 2, 6, 63, 11, 2, 6, 63, 24, 2, 7, 19, 2, 6, 55, 2, 11, 2, 2, 2, 40, 2, 24, 2, 7, 47, 47, 44, 41, 49, 55, 53, 40, 44, 38, 16, 2, 22, 2, 30, 2, 6, 43, 25, 2, 7, 18, 2, 6, 51, 2, 7, 22, 2, 6, 37, 2, 34, 2, 7, 32, 2, 6, 12, 2, 7, 19, 2, 6, 53, 65, 65, 66, 64, 10, 2, 7, 13, 2, 6, 63, 41, 2, 7, 30, 2, 6, 62, 23, 2, 7, 20, 2, 6, 64, 66, 65, 28, 2, 7, 42, 2, 6, 29, 2, 22, 2, 7, 49, 41, 54, 50, 42, 45, 14, 2, 6, 14, 2, 7, 13, 2, 6, 7, 2, 7, 41, 2, 6, 59, 24, 2, 7, 28, 2, 6, 63, 51, 2, 9, 2, 7, 50, 45, 41, 54, 2, 40, 2, 51, 48, 43, 42, 47, 47, 38, 46, 43, 47, 44, 2, 9, 2, 2, 2, 31, 2, 42, 2, 6, 45, 43, 43, 44, 42, 39, 22, 2, 7, 23, 2, 6, 15, 2, 31, 2, 48, 2, 6, 35, 2, 7, 26, 2, 6, 32, 2, 7, 30, 2, 6, 25, 2, 7, 39, 2, 6, 42, 23, 2, 7, 39, 40, 41, 48, 41, 42, 2, 6, 44, 2, 7, 32, 2, 6, 47, 45, 50, 48, 45, 2, 7, 22, 2, 9, 2, 6, 32, 2, 6, 48, 2, 26, 2, 40, 42, 42, 45, 49, 39, 36, 42, 42, 43, 54, 45, 45, 54, 47, 45, 38, 44, 38, 36, 46, 44, 40, 40, 48, 46, 40, 46, 43, 40, 48, 43, 40, 46, 45, 2, 9, 2, 2, 2, 42, 2, 28, 2, 8, 28, 2, 7, 38, 32, 2, 8, 22, 2, 7, 47, 61, 53, 51, 38, 44, 51, 57, 53, 42, 53, 46, 2, 8, 18, 2, 17, 2, 43, 46, 39, 42, 2, 34, 2, 6, 44, 2, 8, 19, 2, 15, 37, 24, 33, 28, 2, 8, 43, 2, 6, 31, 10, 31, 27, 36, 28, 2, 8, 20, 2, 6, 17, 10, 43, 2, 15, 2, 8, 27, 2, 6, 10, 37, 37, 30, 2, 7, 26, 2, 6, 62, 67, 13, 2, 7, 26, 2, 6, 67, 25, 10, 39, 34, 33, 28, 2, 44, 35, 37, 27, 2, 7, 17, 2, 6, 53, 10, 33, 32, 43, 34, 2, 38, 30, 40, 40, 2, 7, 30, 2, 6, 59, 66, 63, 66, 33, 2, 9, 2, 7, 52, 2, 17, 2, 49, 52, 48, 45, 49, 45, 58, 56, 45, 45, 51, 44, 44, 47, 41, 48, 40, 42, 43, 43, 29, 2, 19, 2, 8, 28, 2, 7, 49, 2, 22, 2, 21, 2, 7, 25, 37, 46, 40, 51, 42, 37, 40, 46, 52, 40, 2, 8, 45, 44, 2, 19, 2, 7, 22, 2, 42, 2, 7, 51, 2, 8, 20, 2, 7, 28, 2, 8, 19, 2, 33, 2, 7, 49, 20, 2, 8, 23, 2, 7, 54, 47, 47, 20, 2, 7, 29, 43, 47, 42, 45, 45, 54, 13, 2, 7, 21, 2, 7, 7, 2, 8, 17, 2, 7, 26, 2, 7, 45, 51, 47, 45, 45, 44, 31, 2, 7, 21, 2, 7, 29, 46, 32, 2, 7, 15, 37, 56, 54, 19, 2, 7, 23, 2, 7, 26, 2, 7, 49, 44, 28, 2, 7, 20, 41, 45, 39, 43, 26, 2, 8, 27, 2, 7, 30, 2, 58, 11, 2, 51, 46, 49, 46, 42, 46, 43, 46, 43, 27, 2, 6, 10, 40, 35, 43, 2, 25, 2, 7, 50, 25, 2, 6, 59, 67, 20, 2, 7, 34, 2, 6, 55, 54, 2, 7, 58, 2, 6, 63, 58, 67, 67, 49, 10, 43, 2, 7, 47, 40, 2, 6, 10, 32, 32, 26, 27, 30, 2, 36, 29, 30, 29, 31, 2, 57, 2, 9, 2, 7, 25, 2, 7, 42, 37, 51, 50, 36, 49, 49, 37, 45, 44, 25, 2, 7, 17, 43, 49, 41, 50, 33, 2, 7, 15, 50, 24, 2, 11, 2, 2, 2, 39, 2, 32, 2, 6, 41, 2, 10, 51, 2, 6, 19, 2, 17, 2, 43, 47, 2, 18, 2, 11, 21, 2, 6, 25, 2, 9, 59, 67, 50, 2, 6, 52, 60, 63, 63, 66, 63, 67, 67, 66, 66, 66, 65, 65, 58, 44, 2, 51, 47, 36, 2, 11, 2, 2, 2, 40, 2, 27, 2, 7, 47, 47, 46, 44, 18, 2, 7, 31, 44, 39, 45, 29, 2, 7, 29, 49, 53, 46, 47, 43, 48, 43, 39, 48, 49, 52, 49, 43, 38, 33, 2, 7, 36, 41, 44, 42, 49, 2, 7, 53, 44, 49, 52, 43, 48, 2, 22, 2, 21, 2, 7, 32, 42, 2, 7, 32, 2, 7, 45, 50, 27, 2, 7, 31, 11, 2, 19, 2, 65, 63, 63, 64, 2, 52, 41, 2, 7, 20, 2, 7, 38, 44, 20, 2, 7, 45, 40, 46, 21, 2, 7, 25, 42, 26, 2, 7, 14, 41, 2, 7, 45, 46, 43, 36, 47, 42, 49, 23, 2, 7, 27, 38, 28, 2, 7, 17, 49, 45, 47, 43, 42, 27, 2, 7, 29, 2, 7, 36, 44, 45, 44, 52, 37, 51, 50, 45, 47, 43, 51, 42, 28, 2, 7, 17, 2, 7, 11, 2, 7, 23, 2, 7, 16, 2, 7, 42, 28, 2, 7, 28, 37, 39, 38, 46, 54, 47, 46, 37, 43, 44, 21, 2, 7, 28, 2, 7, 39, 43, 25, 2, 7, 19, 2, 7, 48, 40, 39, 42, 43, 45, 42, 37, 45, 55, 40, 49, 52, 56, 45, 44, 21, 2, 7, 34, 2, 7, 46, 51, 51, 47, 49, 38, 52, 44, 46, 47, 44, 46, 30, 2, 7, 14, 44, 38, 40, 44, 45, 47, 51, 52, 18, 2, 7, 30, 47, 47, 54, 51, 47, 49, 47, 9, 44, 48, 53, 47, 44, 29, 2, 16, 2, 23, 2, 8, 41, 55, 2, 7, 20, 2, 8, 41, 50, 44, 53, 45, 53, 48, 46, 42, 53, 45, 48, 39, 38, 45, 49, 47, 17, 2, 7, 28, 2, 8, 19, 2, 7, 44, 42, 43, 50, 41, 49, 31, 2, 9, 2, 7, 25, 40, 43, 25, 2, 11, 2, 2, 2, 8, 2, 24, 2, 38, 2, 10, 59, 26, 2, 10, 64, 57, 2, 10, 65, 2, 10, 21, 2, 10, 60, 66, 63, 39, 2, 10, 38, 2, 10, 59, 66, 66, 64, 56, 2, 10, 18, 2, 10, 39, 2, 10, 53, 67, 2, 10, 59, 67, 62, 67, 28, 2, 10, 21, 2, 10, 39, 2, 10, 19, 2, 10, 62, 65, 63, 29, 2, 10, 8, 2, 10, 60, 31, 2, 10, 64, 2, 10, 60, 63, 61, 67, 2, 10, 65, 2, 10, 31, 2, 10, 24, 2, 10, 7, 2, 10, 22, 2, 44, 2, 10, 60, 61, 62, 61, 9, 2, 22, 2, 19, 2, 40, 35, 49, 43, 2, 6, 62, 15, 2, 6, 52, 2, 6, 63, 8, 2, 10, 10, 38, 36, 39, 35, 2, 22, 2, 6, 61, 64, 63, 64, 15, 2, 6, 20, 2, 6, 61, 67, 57, 20, 2, 6, 14, 2, 6, 61, 65, 64, 62, 7, 2, 10, 10, 36, 33, 36, 32, 2, 28, 2, 6, 61, 66, 65, 65, 65, 64, 65, 65, 64, 65, 65, 66, 11, 2, 6, 26, 2, 6, 39, 2, 6, 37, 2, 6, 63, 54, 2, 10, 12, 10, 36, 32, 2, 6, 50, 2, 10, 67, 36, 2, 6, 62, 52, 2, 10, 59, 2, 6, 32, 2, 10, 18, 2, 6, 18, 2, 10, 19, 2, 6, 27, 2, 10, 60, 2, 6, 58, 62, 64, 66, 57, 2, 10, 60, 39, 2, 6, 25, 2, 10, 60, 64, 15, 2, 6, 42, 2, 10, 59, 47, 2, 6, 6, 2, 10, 66, 2, 6, 18, 2, 10, 27, 2, 6, 16, 2, 10, 35, 2, 6, 19, 2, 10, 61, 15, 2, 6, 50, 2, 10, 60, 66, 64, 16, 2, 6, 27, 2, 10, 61, 67, 67, 38, 2, 6, 15, 2, 10, 61, 2, 6, 18, 2, 10, 60, 61, 27, 2, 6, 7, 2, 10, 12, 2, 6, 64, 65, 67, 64, 65, 64, 65, 60, 61, 67, 20, 2, 6, 23, 2, 6, 64, 2, 6, 10, 2, 6, 20, 2, 26, 2, 6, 19, 2, 6, 55, 63, 23, 2, 6, 50, 2, 6, 62, 61, 66, 63, 50, 47, 45, 51, 52, 50, 2, 59, 66, 2, 52, 47, 47, 42, 27, 2, 26, 2, 7, 21, 2, 6, 18, 27, 2, 7, 21, 2, 11, 41, 48, 50, 47, 48, 54, 43, 46, 21, 2, 7, 29, 2, 11, 18, 43, 40, 27, 2, 7, 25, 40, 52, 40, 26, 2, 6, 25, 2, 8, 32, 23, 51, 53, 33, 2, 7, 15, 43, 44, 47, 48, 25, 45, 45, 42, 18, 2, 6, 14, 24, 48, 52, 41, 18, 25, 2, 7, 26, 23, 2, 6, 24, 46, 43, 39, 45, 2, 7, 21, 2, 8, 17, 2, 6, 14, 2, 6, 25, 2, 61, 2, 6, 44, 38, 2, 8, 23, 2, 6, 42, 45, 45, 2, 7, 24, 2, 8, 31, 2, 6, 36, 62, 41, 43, 42, 42, 49, 43, 45, 47, 28, 2, 8, 23, 44, 38, 46, 32, 2, 6, 16, 42, 40, 38, 46, 2, 9, 2, 7, 45, 2, 17, 14, 54, 45, 48, 42, 40, 42, 2, 11, 2, 2, 2, 33, 2, 29, 2, 6, 50, 39, 2, 6, 23, 2, 6, 47, 46, 49, 47, 43, 55, 42, 29, 2, 6, 23, 2, 6, 19, 43, 43, 47, 41, 40, 49, 38, 44, 48, 47, 43, 42, 31, 2, 6, 16, 2, 6, 49, 42, 2, 6, 16, 2, 6, 45, 42, 42, 42, 41, 45, 44, 44, 29, 2, 6, 19, 2, 6, 41, 40, 52, 48, 41, 44, 47, 43, 44, 28, 2, 6, 22, 2, 6, 40, 39, 42, 46, 57, 47, 49, 23, 2, 6, 42, 2, 6, 50, 47, 37, 44, 43, 22, 2, 6, 27, 2, 6, 50, 52, 46, 42, 53, 54, 39, 18, 2, 6, 46, 42, 2, 6, 40, 46, 36, 34, 36, 49, 48, 26, 2, 6, 24, 2, 16, 2, 6, 49, 2, 6, 52, 2, 6, 19, 2, 6, 65, 65, 67, 42, 2, 6, 56, 41, 2, 6, 58, 45, 2, 6, 39, 2, 6, 56, 2, 6, 42, 2, 6, 55, 2, 6, 63, 65, 58, 11, 2, 6, 28, 39, 2, 6, 61, 57, 61, 66, 66, 47, 2, 6, 61, 65, 64, 67, 67, 64, 45, 2, 6, 46, 2, 6, 64, 15, 2, 6, 6, 2, 6, 67, 14, 2, 6, 48, 2, 6, 13, 2, 6, 59, 2, 6, 14, 2, 6, 33, 2, 6, 63, 30, 2, 6, 55, 2, 6, 60, 58, 2, 6, 60, 43, 2, 6, 20, 2, 6, 20, 2, 6, 39, 2, 6, 58, 60, 67, 63, 63, 23, 2, 6, 30, 2, 6, 61, 2, 6, 38, 2, 6, 59, 67, 62, 67, 66, 2, 6, 58, 59, 63, 46, 2, 6, 21, 2, 6, 58, 2, 6, 62, 59, 64, 65, 25, 2, 6, 33, 2, 6, 60, 2, 6, 37, 2, 6, 15, 2, 15, 2, 63, 13, 2, 6, 52, 2, 6, 67, 67, 63, 60, 64, 43, 2, 17, 2, 7, 59, 66, 65, 24, 2, 6, 64, 67, 22, 2, 7, 45, 2, 6, 16, 2, 7, 59, 34, 2, 6, 24, 2, 14, 2, 6, 36, 2, 6, 61, 67, 63, 2, 6, 22, 2, 6, 60, 32, 2, 6, 64, 41, 2, 6, 61, 65, 66, 65, 29, 2, 64, 12, 2, 7, 49, 2, 46, 2, 6, 50, 39, 53, 42, 18, 47, 45, 45, 39, 47, 44, 45, 43, 37, 24, 41, 47, 42, 22, 2, 7, 27, 49, 42, 42, 44, 39, 45, 43, 24, 2, 6, 22, 47, 29, 2, 7, 19, 2, 6, 47, 53, 25, 2, 7, 19, 2, 6, 19, 2, 7, 50, 21, 2, 6, 21, 50, 2, 7, 41, 50, 2, 7, 40, 2, 6, 52, 2, 25, 2, 6, 19, 2, 7, 46, 41, 42, 46, 49, 41, 46, 49, 42, 39, 51, 50, 39, 2, 6, 15, 2, 7, 16, 2, 14, 2, 6, 6, 2, 7, 5, 2, 6, 11, 2, 6, 29, 2, 7, 15, 2, 7, 52, 25, 2, 47, 2, 19, 2, 6, 48, 35, 2, 14, 2, 7, 33, 2, 7, 20, 2, 8, 34, 46, 44, 2, 6, 13, 2, 7, 25, 2, 8, 40, 2, 7, 50, 2, 6, 41, 2, 8, 29, 2, 7, 28, 2, 7, 19, 2, 7, 53, 2, 6, 46, 42, 38, 2, 7, 22, 2, 14, 2, 6, 23, 2, 7, 18, 2, 50, 45, 2, 7, 31, 2, 6, 18, 2, 20, 2, 6, 30, 2, 6, 48, 2, 6, 20, 2, 7, 46, 45, 2, 6, 21, 2, 7, 31, 2, 8, 52, 39, 2, 9, 2, 6, 41, 25, 2, 18, 2, 7, 45, 44, 44, 44, 42, 43, 45, 48, 2, 6, 28, 27, 2, 19, 2, 18, 19, 2, 7, 43, 2, 6, 48, 44, 19, 2, 14, 2, 7, 22, 39, 45, 48, 18, 2, 9, 2, 6, 47, 47, 48, 45, 48, 50, 37, 44, 21, 2, 6, 19, 43, 30, 2, 6, 19, 52, 38, 53, 42, 35, 50, 21, 2, 36, 2, 29, 2, 6, 51, 37, 22, 2, 6, 20, 47, 46, 39, 39, 50, 45, 2, 9, 2, 6, 54, 46, 32, 2, 17, 2, 58, 2, 7, 22, 2, 6, 26, 47, 2, 7, 45, 45, 37, 26, 2, 15, 22, 45, 53, 42, 45, 34, 2, 6, 21, 42, 44, 47, 49, 48, 40, 45, 48, 39, 45, 47, 39, 48, 16, 2, 7, 26, 39, 43, 47, 48, 2, 6, 43, 51, 43, 54, 29, 2, 7, 19, 42, 40, 52, 42, 25, 43, 47, 29, 2, 17, 2, 65, 24]\n"
 370 |      ]
 371 |     }
 372 |    ],
 373 |    "source": [
 374 |     "linelengths=[len(line) for line in open(\"hamlet.txt\")]#poor code as we dont close the file\n",
 375 |     "print linelengths"
 376 |    ]
 377 |   },
 378 |   {
 379 |    "cell_type": "code",
 380 |    "execution_count": 14,
 381 |    "metadata": {
 382 |     "collapsed": false
 383 |    },
 384 |    "outputs": [
 385 |     {
 386 |      "data": {
 387 |       "text/plain": [
 388 |        "(180718, 26.69394387001477, 26.0, 21.029872021427462)"
 389 |       ]
 390 |      },
 391 |      "execution_count": 14,
 392 |      "metadata": {},
 393 |      "output_type": "execute_result"
 394 |     }
 395 |    ],
 396 |    "source": [
 397 |     "sum(linelengths), np.mean(linelengths), np.median(linelengths), np.std(linelengths)"
 398 |    ]
 399 |   },
 400 |   {
 401 |    "cell_type": "markdown",
 402 |    "metadata": {},
 403 |    "source": [
 404 |     "But perhaps we want to access Hamlet word by word and not line by line"
 405 |    ]
 406 |   },
 407 |   {
 408 |    "cell_type": "code",
 409 |    "execution_count": 15,
 410 |    "metadata": {
 411 |     "collapsed": false
 412 |    },
 413 |    "outputs": [
 414 |     {
 415 |      "data": {
 416 |       "text/plain": [
 417 |        "31659"
 418 |       ]
 419 |      },
 420 |      "execution_count": 15,
 421 |      "metadata": {},
 422 |      "output_type": "execute_result"
 423 |     }
 424 |    ],
 425 |    "source": [
 426 |     "hamletfile=open(\"hamlet.txt\")\n",
 427 |     "hamlettext=hamletfile.read()\n",
 428 |     "hamletfile.close()\n",
 429 |     "hamlettokens=hamlettext.split()#split with no arguments splits on whitespace\n",
 430 |     "len(hamlettokens)"
 431 |    ]
 432 |   },
 433 |   {
 434 |    "cell_type": "markdown",
 435 |    "metadata": {},
 436 |    "source": [
 437 |     "One can use the `with` syntax which cretaes a context. The file closing is then done automatically for us."
 438 |    ]
 439 |   },
 440 |   {
 441 |    "cell_type": "code",
 442 |    "execution_count": 15,
 443 |    "metadata": {
 444 |     "collapsed": false
 445 |    },
 446 |    "outputs": [
 447 |     {
 448 |      "name": "stdout",
 449 |      "output_type": "stream",
 450 |      "text": [
 451 |       "31659\n"
 452 |      ]
 453 |     }
 454 |    ],
 455 |    "source": [
 456 |     "with open(\"hamlet.txt\") as hamletfile:\n",
 457 |     "    hamlettext=hamletfile.read()\n",
 458 |     "    hamlettokens=hamlettext.split()\n",
 459 |     "    print len(hamlettokens)"
 460 |    ]
 461 |   },
 462 |   {
 463 |    "cell_type": "markdown",
 464 |    "metadata": {},
 465 |    "source": [
 466 |     "There are roughly 32,000 words in Hamlet."
 467 |    ]
 468 |   },
 469 |   {
 470 |    "cell_type": "markdown",
 471 |    "metadata": {},
 472 |    "source": [
 473 |     "###The indexing of lists"
 474 |    ]
 475 |   },
 476 |   {
 477 |    "cell_type": "code",
 478 |    "execution_count": 44,
 479 |    "metadata": {
 480 |     "collapsed": false
 481 |    },
 482 |    "outputs": [
 483 |     {
 484 |      "name": "stdout",
 485 |      "output_type": "stream",
 486 |      "text": [
 487 |       "XXXX\r\n",
 488 |       "HAMLET, PRINCE OF DENMARK\r\n",
 489 |       "\r\n",
 490 |       "by William Shakespeare\r\n",
 491 |       "\r\n",
 492 |       "\r\n",
 493 |       "\r\n",
 494 |       "\r\n",
 495 |       "PERSONS REPRESENTED.\r\n",
 496 |       "\r\n",
 497 |       "Claudius, King of Denmark.\r\n",
 498 |       "Hamlet, Son to the former, and Nephew to the present King.\r\n",
 499 |       "Polonius, Lord Chamberlain.\r\n",
 500 |       "Horatio, Friend to Hamlet.\r\n",
 501 |       "Laertes, Son to Polonius.\r\n",
 502 |       "Voltimand, Courtier.\r\n",
 503 |       "Cornelius, Courtier.\r\n",
 504 |       "Rosencrantz, Courtier.\r\n",
 505 |       "Guildenstern, Courtier.\r\n",
 506 |       "Osric, Courtier.\r\n",
 507 |       "A Gentleman, Courtier.\r\n",
 508 |       "A Priest.\r\n",
 509 |       "Marcellus, Officer.\r\n",
 510 |       "Bernardo, Officer.\r\n",
 511 |       "Francisco, a Soldier\r\n",
 512 |       "Reynaldo, Servant to Polonius.\r\n",
 513 |       "Players.\r\n",
 514 |       "Two Clowns, Grave-diggers.\r\n",
 515 |       "Fortinbras, Prince of Norway.\r\n",
 516 |       "A Captain.\r\n",
 517 |       "English Ambassadors.\r\n",
 518 |       "Ghost of Hamlet's Father.\r\n",
 519 |       "\r\n",
 520 |       "Gertrude, Queen of Denmark, and Mother of Hamlet.\r\n",
 521 |       "Ophelia, Daughter to Polonius.\r\n",
 522 |       "\r\n",
 523 |       "Lords, Ladies, Officers, Soldiers, Sailors, Messengers, and other\r\n",
 524 |       "Attendants.\r\n",
 525 |       "\r\n",
 526 |       "SCENE. Elsinore.\r\n",
 527 |       "\r\n",
 528 |       "\r\n",
 529 |       "\r\n",
 530 |       "ACT I.\r\n",
 531 |       "\r\n",
 532 |       "Scene I. Elsinore. A platform before the Castle.\r\n",
 533 |       "\r\n",
 534 |       "[Francisco at his post. Enter to him Bernardo.]\r\n",
 535 |       "\r\n",
 536 |       "Ber.\r\n",
 537 |       "Who's there?\r\n",
 538 |       "\r\n",
 539 |       "Fran.\r\n",
 540 |       "Nay, answer me: stand, and u\n"
 541 |      ]
 542 |     }
 543 |    ],
 544 |    "source": [
 545 |     "print hamlettext[:1000]#first 1000 characters from Hamlet."
 546 |    ]
 547 |   },
 548 |   {
 549 |    "cell_type": "code",
 550 |    "execution_count": 45,
 551 |    "metadata": {
 552 |     "collapsed": false
 553 |    },
 554 |    "outputs": [
 555 |     {
 556 |      "name": "stdout",
 557 |      "output_type": "stream",
 558 |      "text": [
 559 |       "nd, in this upshot, purposes mistook\r\n",
 560 |       "Fall'n on the inventors' heads: all this can I\r\n",
 561 |       "Truly deliver.\r\n",
 562 |       "\r\n",
 563 |       "Fort.\r\n",
 564 |       "Let us haste to hear it,\r\n",
 565 |       "And call the noblest to the audience.\r\n",
 566 |       "For me, with sorrow I embrace my fortune:\r\n",
 567 |       "I have some rights of memory in this kingdom,\r\n",
 568 |       "Which now, to claim my vantage doth invite me.\r\n",
 569 |       "\r\n",
 570 |       "Hor.\r\n",
 571 |       "Of that I shall have also cause to speak,\r\n",
 572 |       "And from his mouth whose voice will draw on more:\r\n",
 573 |       "But let this same be presently perform'd,\r\n",
 574 |       "Even while men's minds are wild: lest more mischance\r\n",
 575 |       "On plots and errors happen.\r\n",
 576 |       "\r\n",
 577 |       "Fort.\r\n",
 578 |       "Let four captains\r\n",
 579 |       "Bear Hamlet like a soldier to the stage;\r\n",
 580 |       "For he was likely, had he been put on,\r\n",
 581 |       "To have prov'd most royally: and, for his passage,\r\n",
 582 |       "The soldiers' music and the rites of war\r\n",
 583 |       "Speak loudly for him.--\r\n",
 584 |       "Take up the bodies.--Such a sight as this\r\n",
 585 |       "Becomes the field, but here shows much amiss.\r\n",
 586 |       "Go, bid the soldiers shoot.\r\n",
 587 |       "\r\n",
 588 |       "[A dead march.]\r\n",
 589 |       "\r\n",
 590 |       "[Exeunt, bearing off the dead bodies; after the which a peal of\r\n",
 591 |       "ordnance is shot off.]\r\n",
 592 |       "\n"
 593 |      ]
 594 |     }
 595 |    ],
 596 |    "source": [
 597 |     "print hamlettext[-1000:]#and last 1000 characters from Hamlet."
 598 |    ]
 599 |   },
 600 |   {
 601 |    "cell_type": "markdown",
 602 |    "metadata": {},
 603 |    "source": [
 604 |     "Lets split the word tokens. The first one below reads, give me the second, third, and fourth words (remember that python is 0 indexed). Try and figure what the others mean."
 605 |    ]
 606 |   },
 607 |   {
 608 |    "cell_type": "code",
 609 |    "execution_count": 16,
 610 |    "metadata": {
 611 |     "collapsed": false
 612 |    },
 613 |    "outputs": [
 614 |     {
 615 |      "name": "stdout",
 616 |      "output_type": "stream",
 617 |      "text": [
 618 |       "['HAMLET,', 'PRINCE', 'OF'] ['\\xef\\xbb\\xbfXXXX', 'HAMLET,', 'PRINCE', 'OF'] XXXX off.]\n"
 619 |      ]
 620 |     }
 621 |    ],
 622 |    "source": [
 623 |     "print hamlettokens[1:4], hamlettokens[:4], hamlettokens[0], hamlettokens[-1]"
 624 |    ]
 625 |   },
 626 |   {
 627 |    "cell_type": "code",
 628 |    "execution_count": 17,
 629 |    "metadata": {
 630 |     "collapsed": false
 631 |    },
 632 |    "outputs": [
 633 |     {
 634 |      "data": {
 635 |       "text/plain": [
 636 |        "['HAMLET,', 'OF', 'by', 'Shakespeare']"
 637 |       ]
 638 |      },
 639 |      "execution_count": 17,
 640 |      "metadata": {},
 641 |      "output_type": "execute_result"
 642 |     }
 643 |    ],
 644 |    "source": [
 645 |     "hamlettokens[1:8:2]#get every 2nd world between the 2nd and the 9th: ie 2nd, 4th, 6th, and 8th"
 646 |    ]
 647 |   },
 648 |   {
 649 |    "cell_type": "markdown",
 650 |    "metadata": {},
 651 |    "source": [
 652 |     "range and xrange get the list of integers upto N. But xrange behaves like an iterator. The reason for this is that there is no point generaing all os a million integers. We can just add 1 to the previous one and save memory. So we trade off storage for computation."
 653 |    ]
 654 |   },
 655 |   {
 656 |    "cell_type": "code",
 657 |    "execution_count": 18,
 658 |    "metadata": {
 659 |     "collapsed": false
 660 |    },
 661 |    "outputs": [
 662 |     {
 663 |      "data": {
 664 |       "text/plain": [
 665 |        "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
 666 |       ]
 667 |      },
 668 |      "execution_count": 18,
 669 |      "metadata": {},
 670 |      "output_type": "execute_result"
 671 |     }
 672 |    ],
 673 |    "source": [
 674 |     "mylist=[]\n",
 675 |     "for i in xrange(10):\n",
 676 |     "    mylist.append(i)\n",
 677 |     "mylist"
 678 |    ]
 679 |   },
 680 |   {
 681 |    "cell_type": "markdown",
 682 |    "metadata": {},
 683 |    "source": [
 684 |     "## Dictionaries\n",
 685 |     "\n",
 686 |     "These are the bread and butter. You will use them a lot. They even duck like lists. But be careful how."
 687 |    ]
 688 |   },
 689 |   {
 690 |    "cell_type": "code",
 691 |    "execution_count": 19,
 692 |    "metadata": {
 693 |     "collapsed": false
 694 |    },
 695 |    "outputs": [
 696 |     {
 697 |      "name": "stdout",
 698 |      "output_type": "stream",
 699 |      "text": [
 700 |       "['three', 'two', 'one'] [('three', 3), ('two', 2), ('one', 1)] [3, 2, 1]\n"
 701 |      ]
 702 |     }
 703 |    ],
 704 |    "source": [
 705 |     "adict={'one':1, 'two': 2, 'three': 3}\n",
 706 |     "print [i for i in adict], [(k,v) for k,v in adict.items()], adict.values()"
 707 |    ]
 708 |   },
 709 |   {
 710 |    "cell_type": "markdown",
 711 |    "metadata": {},
 712 |    "source": [
 713 |     "The keys do not have to be strings. From python 2.7 you can use dictionary comprehensions as well"
 714 |    ]
 715 |   },
 716 |   {
 717 |    "cell_type": "code",
 718 |    "execution_count": 20,
 719 |    "metadata": {
 720 |     "collapsed": false
 721 |    },
 722 |    "outputs": [
 723 |     {
 724 |      "data": {
 725 |       "text/plain": [
 726 |        "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}"
 727 |       ]
 728 |      },
 729 |      "execution_count": 20,
 730 |      "metadata": {},
 731 |      "output_type": "execute_result"
 732 |     }
 733 |    ],
 734 |    "source": [
 735 |     "mydict ={k:v for (k,v) in zip(alist, asquaredlist)}\n",
 736 |     "mydict"
 737 |    ]
 738 |   },
 739 |   {
 740 |    "cell_type": "markdown",
 741 |    "metadata": {},
 742 |    "source": [
 743 |     "You can construct then nicely using the function `dict`."
 744 |    ]
 745 |   },
 746 |   {
 747 |    "cell_type": "code",
 748 |    "execution_count": 46,
 749 |    "metadata": {
 750 |     "collapsed": false
 751 |    },
 752 |    "outputs": [
 753 |     {
 754 |      "data": {
 755 |       "text/plain": [
 756 |        "{'a': 1, 'b': 2}"
 757 |       ]
 758 |      },
 759 |      "execution_count": 46,
 760 |      "metadata": {},
 761 |      "output_type": "execute_result"
 762 |     }
 763 |    ],
 764 |    "source": [
 765 |     "dict(a=1, b=2)"
 766 |    ]
 767 |   },
 768 |   {
 769 |    "cell_type": "markdown",
 770 |    "metadata": {},
 771 |    "source": [
 772 |     "###and conversion to json"
 773 |    ]
 774 |   },
 775 |   {
 776 |    "cell_type": "code",
 777 |    "execution_count": 21,
 778 |    "metadata": {
 779 |     "collapsed": false
 780 |    },
 781 |    "outputs": [],
 782 |    "source": [
 783 |     "import json"
 784 |    ]
 785 |   },
 786 |   {
 787 |    "cell_type": "code",
 788 |    "execution_count": 22,
 789 |    "metadata": {
 790 |     "collapsed": false
 791 |    },
 792 |    "outputs": [
 793 |     {
 794 |      "name": "stdout",
 795 |      "output_type": "stream",
 796 |      "text": [
 797 |       "{\"1\": 1, \"2\": 4, \"3\": 9, \"4\": 16, \"5\": 25}\n"
 798 |      ]
 799 |     }
 800 |    ],
 801 |    "source": [
 802 |     "s=json.dumps(mydict)\n",
 803 |     "print s"
 804 |    ]
 805 |   },
 806 |   {
 807 |    "cell_type": "code",
 808 |    "execution_count": 23,
 809 |    "metadata": {
 810 |     "collapsed": false
 811 |    },
 812 |    "outputs": [
 813 |     {
 814 |      "data": {
 815 |       "text/plain": [
 816 |        "{u'1': 1, u'2': 4, u'3': 9, u'4': 16, u'5': 25}"
 817 |       ]
 818 |      },
 819 |      "execution_count": 23,
 820 |      "metadata": {},
 821 |      "output_type": "execute_result"
 822 |     }
 823 |    ],
 824 |    "source": [
 825 |     "json.loads(s)"
 826 |    ]
 827 |   },
 828 |   {
 829 |    "cell_type": "markdown",
 830 |    "metadata": {},
 831 |    "source": [
 832 |     "## Strings\n",
 833 |     "\n",
 834 |     "Basically they behave like immutable lists"
 835 |    ]
 836 |   },
 837 |   {
 838 |    "cell_type": "code",
 839 |    "execution_count": 24,
 840 |    "metadata": {
 841 |     "collapsed": false
 842 |    },
 843 |    "outputs": [
 844 |     {
 845 |      "name": "stdout",
 846 |      "output_type": "stream",
 847 |      "text": [
 848 |       "off.]\n"
 849 |      ]
 850 |     }
 851 |    ],
 852 |    "source": [
 853 |     "lastword=hamlettokens[-1]\n",
 854 |     "print(lastword)"
 855 |    ]
 856 |   },
 857 |   {
 858 |    "cell_type": "code",
 859 |    "execution_count": 25,
 860 |    "metadata": {
 861 |     "collapsed": false
 862 |    },
 863 |    "outputs": [
 864 |     {
 865 |      "ename": "TypeError",
 866 |      "evalue": "'str' object does not support item assignment",
 867 |      "output_type": "error",
 868 |      "traceback": [
 869 |       "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
 870 |       "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
 871 |       "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mlastword\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"k\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
 872 |       "\u001b[0;31mTypeError\u001b[0m: 'str' object does not support item assignment"
 873 |      ]
 874 |     }
 875 |    ],
 876 |    "source": [
 877 |     "lastword[-2]=\"k\"#cant change a part of a string"
 878 |    ]
 879 |   },
 880 |   {
 881 |    "cell_type": "code",
 882 |    "execution_count": 26,
 883 |    "metadata": {
 884 |     "collapsed": false
 885 |    },
 886 |    "outputs": [
 887 |     {
 888 |      "data": {
 889 |       "text/plain": [
 890 |        "'.'"
 891 |       ]
 892 |      },
 893 |      "execution_count": 26,
 894 |      "metadata": {},
 895 |      "output_type": "execute_result"
 896 |     }
 897 |    ],
 898 |    "source": [
 899 |     "lastword[-2]"
 900 |    ]
 901 |   },
 902 |   {
 903 |    "cell_type": "code",
 904 |    "execution_count": null,
 905 |    "metadata": {
 906 |     "collapsed": true
 907 |    },
 908 |    "outputs": [],
 909 |    "source": [
 910 |     "You can join a list with a separator to make a string."
 911 |    ]
 912 |   },
 913 |   {
 914 |    "cell_type": "code",
 915 |    "execution_count": 27,
 916 |    "metadata": {
 917 |     "collapsed": false
 918 |    },
 919 |    "outputs": [
 920 |     {
 921 |      "data": {
 922 |       "text/plain": [
 923 |        "\"\\xef\\xbb\\xbfXXXX,HAMLET,,PRINCE,OF,DENMARK,by,William,Shakespeare,PERSONS,REPRESENTED.,Claudius,,King,of,Denmark.,Hamlet,,Son,to,the,former,,and,Nephew,to,the,present,King.,Polonius,,Lord,Chamberlain.,Horatio,,Friend,to,Hamlet.,Laertes,,Son,to,Polonius.,Voltimand,,Courtier.,Cornelius,,Courtier.,Rosencrantz,,Courtier.,Guildenstern,,Courtier.,Osric,,Courtier.,A,Gentleman,,Courtier.,A,Priest.,Marcellus,,Officer.,Bernardo,,Officer.,Francisco,,a,Soldier,Reynaldo,,Servant,to,Polonius.,Players.,Two,Clowns,,Grave-diggers.,Fortinbras,,Prince,of,Norway.,A,Captain.,English,Ambassadors.,Ghost,of,Hamlet's,Father.,Gertrude,,Queen,of,Denmark,,and,Mother,of,Hamlet.,Ophelia,,Daughter,to,Polonius.,Lords,,Ladies,,Officers,,Soldiers,,Sailors,,Messengers,,and,other,Attendants.,SCENE.,Elsinore.,ACT,I.,Scene,I.,Elsinore.,A,platform,before,the,Castle.,[Francisco,at,his,post.,Enter,to,him,Bernardo.],Ber.,Who's,there?,Fran.,Nay,,answer,me:,stand,,and,unfold,yourself.,Ber.,Long,live,the,king!,Fran.,Bernardo?,Ber.,He.,Fra\""
 924 |       ]
 925 |      },
 926 |      "execution_count": 27,
 927 |      "metadata": {},
 928 |      "output_type": "execute_result"
 929 |     }
 930 |    ],
 931 |    "source": [
 932 |     "wierdstring=\",\".join(hamlettokens)\n",
 933 |     "wierdstring[:1000]"
 934 |    ]
 935 |   },
 936 |   {
 937 |    "cell_type": "markdown",
 938 |    "metadata": {},
 939 |    "source": [
 940 |     "## Functions\n",
 941 |     "\n",
 942 |     "Functions are even more the bread and butter. You'll see them as methods on objects, or standing alone by themselves."
 943 |    ]
 944 |   },
 945 |   {
 946 |    "cell_type": "code",
 947 |    "execution_count": 28,
 948 |    "metadata": {
 949 |     "collapsed": false
 950 |    },
 951 |    "outputs": [
 952 |     {
 953 |      "data": {
 954 |       "text/plain": [
 955 |        "(25, 125)"
 956 |       ]
 957 |      },
 958 |      "execution_count": 28,
 959 |      "metadata": {},
 960 |      "output_type": "execute_result"
 961 |     }
 962 |    ],
 963 |    "source": [
 964 |     "def square(x):\n",
 965 |     "    return(x*x)\n",
 966 |     "def cube(x):\n",
 967 |     "    return x*x*x\n",
 968 |     "square(5),cube(5)"
 969 |    ]
 970 |   },
 971 |   {
 972 |    "cell_type": "code",
 973 |    "execution_count": 29,
 974 |    "metadata": {
 975 |     "collapsed": false
 976 |    },
 977 |    "outputs": [
 978 |     {
 979 |      "name": "stdout",
 980 |      "output_type": "stream",
 981 |      "text": [
 982 |       " \n"
 983 |      ]
 984 |     }
 985 |    ],
 986 |    "source": [
 987 |     "print square, type(cube)"
 988 |    ]
 989 |   },
 990 |   {
 991 |    "cell_type": "markdown",
 992 |    "metadata": {},
 993 |    "source": [
 994 |     "In Python, functions are \"first-class\". This is just a fancy way of saying, you can pass functions to other functions"
 995 |    ]
 996 |   },
 997 |   {
 998 |    "cell_type": "code",
 999 |    "execution_count": 47,
1000 |    "metadata": {
1001 |     "collapsed": false
1002 |    },
1003 |    "outputs": [
1004 |     {
1005 |      "name": "stdout",
1006 |      "output_type": "stream",
1007 |      "text": [
1008 |       "3 4 \n"
1009 |      ]
1010 |     },
1011 |     {
1012 |      "data": {
1013 |       "text/plain": [
1014 |        "25"
1015 |       ]
1016 |      },
1017 |      "execution_count": 47,
1018 |      "metadata": {},
1019 |      "output_type": "execute_result"
1020 |     }
1021 |    ],
1022 |    "source": [
1023 |     "def sum_of_anything(x,y,f):\n",
1024 |     "    print x,y,f\n",
1025 |     "    return(f(x) + f(y))\n",
1026 |     "sum_of_anything(3,4,square)"
1027 |    ]
1028 |   },
1029 |   {
1030 |    "cell_type": "markdown",
1031 |    "metadata": {},
1032 |    "source": [
1033 |     "Python functions can have positional arguments and keyword arguments. Positional arguments are stored in a tuple, and keyword arguments in a dictionary. Note the \"starred\" syntax"
1034 |    ]
1035 |   },
1036 |   {
1037 |    "cell_type": "code",
1038 |    "execution_count": 50,
1039 |    "metadata": {
1040 |     "collapsed": false
1041 |    },
1042 |    "outputs": [
1043 |     {
1044 |      "name": "stdout",
1045 |      "output_type": "stream",
1046 |      "text": [
1047 |       "got 1 3 () {}\n",
1048 |       "1\n",
1049 |       "got 1 3 (4,) {'c': 2, 'd': 1}\n",
1050 |       "1\n"
1051 |      ]
1052 |     }
1053 |    ],
1054 |    "source": [
1055 |     "def f(a,b,*posargs,**dictargs):\n",
1056 |     "    print \"got\",a,b,posargs, dictargs\n",
1057 |     "    return a\n",
1058 |     "print f(1,3)\n",
1059 |     "print f(1,3,4,d=1,c=2)"
1060 |    ]
1061 |   },
1062 |   {
1063 |    "cell_type": "markdown",
1064 |    "metadata": {},
1065 |    "source": [
1066 |     ">**YOUR TURN** create a dictionary with keys the integers upto and including 10, and values the cubes of these dictionaries"
1067 |    ]
1068 |   },
1069 |   {
1070 |    "cell_type": "code",
1071 |    "execution_count": null,
1072 |    "metadata": {
1073 |     "collapsed": false
1074 |    },
1075 |    "outputs": [],
1076 |    "source": [
1077 |     "#your code here"
1078 |    ]
1079 |   },
1080 |   {
1081 |    "cell_type": "markdown",
1082 |    "metadata": {},
1083 |    "source": [
1084 |     "##Booleans and Control-flow\n",
1085 |     "\n",
1086 |     "Lets test for belonging..."
1087 |    ]
1088 |   },
1089 |   {
1090 |    "cell_type": "code",
1091 |    "execution_count": 32,
1092 |    "metadata": {
1093 |     "collapsed": false
1094 |    },
1095 |    "outputs": [
1096 |     {
1097 |      "data": {
1098 |       "text/plain": [
1099 |        "True"
1100 |       ]
1101 |      },
1102 |      "execution_count": 32,
1103 |      "metadata": {},
1104 |      "output_type": "execute_result"
1105 |     }
1106 |    ],
1107 |    "source": [
1108 |     "a=[1,2,3,4,5]\n",
1109 |     "1 in a"
1110 |    ]
1111 |   },
1112 |   {
1113 |    "cell_type": "code",
1114 |    "execution_count": 33,
1115 |    "metadata": {
1116 |     "collapsed": false
1117 |    },
1118 |    "outputs": [
1119 |     {
1120 |      "data": {
1121 |       "text/plain": [
1122 |        "False"
1123 |       ]
1124 |      },
1125 |      "execution_count": 33,
1126 |      "metadata": {},
1127 |      "output_type": "execute_result"
1128 |     }
1129 |    ],
1130 |    "source": [
1131 |     "6 in a"
1132 |    ]
1133 |   },
1134 |   {
1135 |    "cell_type": "markdown",
1136 |    "metadata": {},
1137 |    "source": [
1138 |     "Python supports if/elif/else clauses for multi-way conditionals"
1139 |    ]
1140 |   },
1141 |   {
1142 |    "cell_type": "code",
1143 |    "execution_count": 34,
1144 |    "metadata": {
1145 |     "collapsed": false
1146 |    },
1147 |    "outputs": [
1148 |     {
1149 |      "name": "stdout",
1150 |      "output_type": "stream",
1151 |      "text": [
1152 |       "One\n"
1153 |      ]
1154 |     }
1155 |    ],
1156 |    "source": [
1157 |     "def do_it(x):\n",
1158 |     "    if x==1:\n",
1159 |     "        print \"One\"\n",
1160 |     "    elif x==2:\n",
1161 |     "        print \"Two\"\n",
1162 |     "    else:\n",
1163 |     "        print x\n",
1164 |     "do_it(1)"
1165 |    ]
1166 |   },
1167 |   {
1168 |    "cell_type": "code",
1169 |    "execution_count": 35,
1170 |    "metadata": {
1171 |     "collapsed": false
1172 |    },
1173 |    "outputs": [
1174 |     {
1175 |      "name": "stdout",
1176 |      "output_type": "stream",
1177 |      "text": [
1178 |       "Two\n",
1179 |       "3\n"
1180 |      ]
1181 |     },
1182 |     {
1183 |      "data": {
1184 |       "text/plain": [
1185 |        "(None, None)"
1186 |       ]
1187 |      },
1188 |      "execution_count": 35,
1189 |      "metadata": {},
1190 |      "output_type": "execute_result"
1191 |     }
1192 |    ],
1193 |    "source": [
1194 |     "do_it(2), do_it(3)"
1195 |    ]
1196 |   },
1197 |   {
1198 |    "cell_type": "markdown",
1199 |    "metadata": {},
1200 |    "source": [
1201 |     "You can `break` out of a loop based on a condition. The loop below is a for loop."
1202 |    ]
1203 |   },
1204 |   {
1205 |    "cell_type": "code",
1206 |    "execution_count": 36,
1207 |    "metadata": {
1208 |     "collapsed": false
1209 |    },
1210 |    "outputs": [
1211 |     {
1212 |      "name": "stdout",
1213 |      "output_type": "stream",
1214 |      "text": [
1215 |       "0\n",
1216 |       "1\n",
1217 |       "2\n",
1218 |       "3\n",
1219 |       "4\n",
1220 |       "5\n",
1221 |       "6\n"
1222 |      ]
1223 |     }
1224 |    ],
1225 |    "source": [
1226 |     "for i in range(10):\n",
1227 |     "    print i\n",
1228 |     "    if (i > 5):\n",
1229 |     "        break"
1230 |    ]
1231 |   },
1232 |   {
1233 |    "cell_type": "markdown",
1234 |    "metadata": {},
1235 |    "source": [
1236 |     "While loops are also supported. `continue` continues to the next iteration of the loop skipping all the code below, while `break` breaks out of it."
1237 |    ]
1238 |   },
1239 |   {
1240 |    "cell_type": "code",
1241 |    "execution_count": 37,
1242 |    "metadata": {
1243 |     "collapsed": false
1244 |    },
1245 |    "outputs": [
1246 |     {
1247 |      "name": "stdout",
1248 |      "output_type": "stream",
1249 |      "text": [
1250 |       "0\n",
1251 |       "1\n",
1252 |       "2\n",
1253 |       "3\n",
1254 |       "4\n"
1255 |      ]
1256 |     }
1257 |    ],
1258 |    "source": [
1259 |     "i=0\n",
1260 |     "while i < 10:\n",
1261 |     "    print i\n",
1262 |     "    i=i+1\n",
1263 |     "    if i < 5:\n",
1264 |     "        continue\n",
1265 |     "    else:\n",
1266 |     "        break\n"
1267 |    ]
1268 |   },
1269 |   {
1270 |    "cell_type": "markdown",
1271 |    "metadata": {},
1272 |    "source": [
1273 |     "## Exceptions\n",
1274 |     "\n",
1275 |     "This is the way to catch errors."
1276 |    ]
1277 |   },
1278 |   {
1279 |    "cell_type": "code",
1280 |    "execution_count": 38,
1281 |    "metadata": {
1282 |     "collapsed": false
1283 |    },
1284 |    "outputs": [
1285 |     {
1286 |      "name": "stdout",
1287 |      "output_type": "stream",
1288 |      "text": [
1289 |       "(, TypeError('f() takes at least 2 arguments (1 given)',), )\n"
1290 |      ]
1291 |     }
1292 |    ],
1293 |    "source": [
1294 |     "try:\n",
1295 |     "    f(1)#takes atleast 2 arguments\n",
1296 |     "except:\n",
1297 |     "    import sys\n",
1298 |     "    print sys.exc_info()"
1299 |    ]
1300 |   },
1301 |   {
1302 |    "cell_type": "markdown",
1303 |    "metadata": {},
1304 |    "source": [
1305 |     "## All together now\n",
1306 |     "\n",
1307 |     "Lets see what hamlet gives us. We convert all words to lower-case"
1308 |    ]
1309 |   },
1310 |   {
1311 |    "cell_type": "code",
1312 |    "execution_count": 39,
1313 |    "metadata": {
1314 |     "collapsed": false
1315 |    },
1316 |    "outputs": [
1317 |     {
1318 |      "data": {
1319 |       "text/plain": [
1320 |        "95"
1321 |       ]
1322 |      },
1323 |      "execution_count": 39,
1324 |      "metadata": {},
1325 |      "output_type": "execute_result"
1326 |     }
1327 |    ],
1328 |    "source": [
1329 |     "hamletlctokens=[word.lower() for word in hamlettokens]\n",
1330 |     "hamletlctokens.count(\"thou\")"
1331 |    ]
1332 |   },
1333 |   {
1334 |    "cell_type": "markdown",
1335 |    "metadata": {},
1336 |    "source": [
1337 |     "We then find a unique set of words using python's `set` data structure. We count how often those words occured usinf the `count` method on lists."
1338 |    ]
1339 |   },
1340 |   {
1341 |    "cell_type": "code",
1342 |    "execution_count": 52,
1343 |    "metadata": {
1344 |     "collapsed": false
1345 |    },
1346 |    "outputs": [],
1347 |    "source": [
1348 |     "uniquelctokens=set(hamletlctokens)"
1349 |    ]
1350 |   },
1351 |   {
1352 |    "cell_type": "code",
1353 |    "execution_count": 41,
1354 |    "metadata": {
1355 |     "collapsed": false
1356 |    },
1357 |    "outputs": [],
1358 |    "source": [
1359 |     "tokendict={}\n",
1360 |     "for ut in uniquelctokens:\n",
1361 |     "    tokendict[ut]=hamletlctokens.count(ut)"
1362 |    ]
1363 |   },
1364 |   {
1365 |    "cell_type": "markdown",
1366 |    "metadata": {},
1367 |    "source": [
1368 |     "We find the 100 most used words..."
1369 |    ]
1370 |   },
1371 |   {
1372 |    "cell_type": "code",
1373 |    "execution_count": 42,
1374 |    "metadata": {
1375 |     "collapsed": false
1376 |    },
1377 |    "outputs": [
1378 |     {
1379 |      "data": {
1380 |       "text/plain": [
1381 |        "[('the', 1136),\n",
1382 |        " ('and', 943),\n",
1383 |        " ('to', 720),\n",
1384 |        " ('of', 667),\n",
1385 |        " ('a', 527),\n",
1386 |        " ('my', 512),\n",
1387 |        " ('i', 510),\n",
1388 |        " ('in', 420),\n",
1389 |        " ('you', 412),\n",
1390 |        " ('ham.', 358),\n",
1391 |        " ('that', 337),\n",
1392 |        " ('it', 324),\n",
1393 |        " ('is', 320),\n",
1394 |        " ('his', 295),\n",
1395 |        " ('not', 270),\n",
1396 |        " ('with', 264),\n",
1397 |        " ('this', 250),\n",
1398 |        " ('your', 241),\n",
1399 |        " ('for', 231),\n",
1400 |        " ('but', 228),\n",
1401 |        " ('as', 216),\n",
1402 |        " ('he', 202),\n",
1403 |        " ('be', 201),\n",
1404 |        " ('what', 183),\n",
1405 |        " ('have', 174),\n",
1406 |        " ('will', 149),\n",
1407 |        " ('so', 143),\n",
1408 |        " ('me', 142),\n",
1409 |        " ('we', 132),\n",
1410 |        " ('do', 128),\n",
1411 |        " ('are', 126),\n",
1412 |        " ('him', 122),\n",
1413 |        " ('our', 119),\n",
1414 |        " ('king.', 113),\n",
1415 |        " ('by', 111),\n",
1416 |        " ('hor.', 110),\n",
1417 |        " ('or', 109),\n",
1418 |        " ('if', 109),\n",
1419 |        " ('on', 109),\n",
1420 |        " ('no', 107),\n",
1421 |        " ('shall', 106),\n",
1422 |        " ('thou', 95),\n",
1423 |        " ('all', 95),\n",
1424 |        " ('from', 95),\n",
1425 |        " ('they', 93),\n",
1426 |        " ('let', 92),\n",
1427 |        " ('good', 88),\n",
1428 |        " ('at', 86),\n",
1429 |        " ('thy', 86),\n",
1430 |        " ('pol.', 86),\n",
1431 |        " ('how', 84),\n",
1432 |        " ('most', 82),\n",
1433 |        " ('lord,', 81),\n",
1434 |        " ('her', 76),\n",
1435 |        " ('more', 76),\n",
1436 |        " ('queen.', 76),\n",
1437 |        " ('like', 75),\n",
1438 |        " ('would', 74),\n",
1439 |        " ('was', 73),\n",
1440 |        " (\"'tis\", 70),\n",
1441 |        " ('you,', 66),\n",
1442 |        " ('may', 65),\n",
1443 |        " ('very', 64),\n",
1444 |        " ('laer.', 62),\n",
1445 |        " ('hath', 62),\n",
1446 |        " ('[enter', 61),\n",
1447 |        " ('lord.', 60),\n",
1448 |        " ('did', 59),\n",
1449 |        " ('give', 58),\n",
1450 |        " ('must', 58),\n",
1451 |        " ('oph.', 58),\n",
1452 |        " ('their', 57),\n",
1453 |        " ('o,', 57),\n",
1454 |        " ('know', 57),\n",
1455 |        " (\"i'll\", 56),\n",
1456 |        " ('an', 55),\n",
1457 |        " ('should', 55),\n",
1458 |        " ('which', 55),\n",
1459 |        " ('some', 54),\n",
1460 |        " ('when', 54),\n",
1461 |        " ('come', 54),\n",
1462 |        " ('upon', 53),\n",
1463 |        " ('make', 53),\n",
1464 |        " ('am', 52),\n",
1465 |        " ('such', 51),\n",
1466 |        " ('ros.', 51),\n",
1467 |        " ('than', 51),\n",
1468 |        " ('there', 50),\n",
1469 |        " ('where', 49),\n",
1470 |        " ('now', 48),\n",
1471 |        " ('go', 48),\n",
1472 |        " ('o', 46),\n",
1473 |        " ('us', 46),\n",
1474 |        " ('clown.', 45),\n",
1475 |        " ('much', 44),\n",
1476 |        " ('had', 44),\n",
1477 |        " ('these', 44),\n",
1478 |        " ('them', 44),\n",
1479 |        " ('she', 43),\n",
1480 |        " ('out', 43)]"
1481 |       ]
1482 |      },
1483 |      "execution_count": 42,
1484 |      "metadata": {},
1485 |      "output_type": "execute_result"
1486 |     }
1487 |    ],
1488 |    "source": [
1489 |     "L=sorted(tokendict.iteritems(), key= lambda (k,v):v, reverse=True)[:100]\n",
1490 |     "L"
1491 |    ]
1492 |   },
1493 |   {
1494 |    "cell_type": "markdown",
1495 |    "metadata": {},
1496 |    "source": [
1497 |     "Lets get the top 20 of this and plot a bar chart!"
1498 |    ]
1499 |   },
1500 |   {
1501 |    "cell_type": "code",
1502 |    "execution_count": 43,
1503 |    "metadata": {
1504 |     "collapsed": false
1505 |    },
1506 |    "outputs": [
1507 |     {
1508 |      "name": "stdout",
1509 |      "output_type": "stream",
1510 |      "text": [
1511 |       "[('the', 1136), ('and', 943), ('to', 720), ('of', 667), ('a', 527), ('my', 512), ('i', 510), ('in', 420), ('you', 412), ('ham.', 358), ('that', 337), ('it', 324), ('is', 320), ('his', 295), ('not', 270), ('with', 264), ('this', 250), ('your', 241), ('for', 231), ('but', 228)]\n"
1512 |      ]
1513 |     },
1514 |     {
1515 |      "data": {
1516 |       "image/png": "iVBORw0KGgoAAAANSUhEUgAAAegAAAFVCAYAAAAkBHynAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtcVHXi//H3cNNgwMTQVIyUyOwCLYmleW1bc7ceVhYV\nGGyPtUxbXQu3stLQpGwzYy3dtLRsJ1dlW9pqu2wbm+GltLatbC0zKqQbqGjNDMoMzvz+6Ov8vAIz\nzNEP8Hr+pWfOvM9nPszhzTlnLja/3+8XAAAwSsTxHgAAADgcBQ0AgIEoaAAADERBAwBgIAoaAAAD\nUdAAABioyYL+8MMPlZeXJ0n65JNPNHbsWOXl5WncuHHauXOnJKmkpERXXXWVrr32Wq1evVqStHfv\nXk2ePFljx47V+PHjVVtba92jAACgjWm0oJ988klNnz5dXq9XkvTAAw9oxowZcjgcGjlypJ588knt\n2LFDDodDK1eu1NKlSzVv3jx5PB6tWLFCffv21fLly3XFFVfo8ccfPyYPCACAtqDRgk5JSdGCBQu0\n/7NMHnnkEZ1xxhmSpIaGBnXo0EEfffSRMjMzFR0dLbvdrpSUFG3ZskXvv/++hg4dKkkaMmSI3n77\nbYsfCgAAbUejBT1y5EhFRkYG/p+UlCRJev/997V8+XLdcMMNcrlcio+PD6wTFxcnl8sll8uluLi4\nwDKn02nF+AEAaJOigr3DK6+8okWLFumJJ55Q586dZbfb5Xa7A7e73W7Fx8cftNztdishIaHJ7IaG\nfYqKimxyPQAA2rqgCvqFF15QSUmJHA6HOnXqJElKT09XcXGxPB6P6uvrV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SktL9eabb6q+vl7bt29Xfn6+ysrKtHXrVt1xxx168cUXNX/+fEnS\nddddp8cee0xJSUkhj7u0tFRffvlls54Hzc1bs2aNvv32W3Xv3l3btm1Tenq6Zs6cGVTO1KlTNXr0\naA0bNkwVFRX6wx/+oE6dOqmqqko+n0833HCDfvWrXykvL0/33XefevfurRUrVmjnzp2aNGnSYXkf\nfPCBxo0bp9raWuXk5CghIUF/+ctf1NDQIJvNpgULFuizzz7TE088oZiYGH3//fe67rrr9M477+jT\nTz9Vfn5+oz/Ppva7Z599Vv/617+0Z88ede7cWQsWLAg81//0pz/plltuCXqeH3roIdXV1amgoEAL\nFiwI6v6N5X7xxRf6/PPP5Xa7tWfPHt12221BHTUe6MB5v+6667R48WK99tprWr16tZYsWaKoqCh1\n7dpVxcXFzf7lXVpaqrfeekv19fXatm2bbrrpJvXt21dFRUWKjIxUTEyMioqKtHbtWu3YsaPJ+Rkz\nZoyWLFmi+Ph4nX/++Vq+fLn69eunAQMGqGfPnioqKtKaNWv0ySef6LTTTpPH49HUqVP13Xff6cQT\nT9Sjjz6qqKgj10FTz4sLL7xQ69at0/Lly/XCCy8oIiJCZ599tqZPn37U8bZk37jyyis1YcIEnXji\niRo2bJhuvPHGo26nsLBQlZWVuvfee1VTUyOXy3XQ7+LLLrtMvXv3VnR0tB555JFm/ewkae3atXrr\nrbdUV1enSZMmadasWXrttdcUExOjhx9+WKmpqaqurtbu3bt133336d5772129oGMLOiJEydq69at\nGjJkiKqrqzV79mxt3LhRS5YsUWZmphYsWKDS0lJ16NBBd9xxh9avX69BgwY1mrlt2zZdeuml+sUv\nfqGamhpdf/316tatmzIyMnT33XeruLhY//jHP3ThhRdqw4YNKi0tVX19vS677LKQx+9yuTR48GDl\n5eWpurpaubm5KisrC3VatGrVKp100kl6+OGH5Xa7NWbMGI0YMUKnn356i8tZOniOqqurm/yF3pi6\nujotXbpUr7zyipYtW6aSkhJt2LBBy5YtU2VlpX788UdVV1crMTGxReUshf/o0mazyWaz6auv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1adO3fWmWeeqZqaGp17\n7rnyer2aN29eyK8B6N+/v2666SY5HI6Q7n+o/ePdsGGDXn31Vfl8Pk2ZMqVFeUeSnp4eODUdFxen\nESNGhJxrs9lUVFSk2bNny+/3KyoqSvfff7+kn+Zn/Pjx+vOf/9xo3vnnn69vvvlGNptNAwYMUEVF\nhU444YTAdjIyMvTII48c8Y/6xp7rjT0vDnT66acrNzdXcXFxOvnkk496yny/luwbweybNptNN998\ns+6+++7A7+L77rtPkZGRIe3jNptNu3fv1q9//Wvt2bNHRUVF2rZtm8aPH6+ePXsedBCWmpqqO+64\nQw899FDQ25H4LG4cJxMnTtTdd9+tXr16He+hWKqmpkZ33nmnnn766eM9FMAo7BtNM/IUN9quvXv3\nasyYMerTp0+bL+fXX39d48aN0+9+97vjPRTAKOwbzcMRNAAABuIIGgAAA1HQAAAYiIIGAMBAFDQA\nAAaioAEAMND/A8NudfT377dBAAAAAElFTkSuQmCC\n",
1517 |       "text/plain": [
1518 |        ""
1519 |       ]
1520 |      },
1521 |      "metadata": {},
1522 |      "output_type": "display_data"
1523 |     }
1524 |    ],
1525 |    "source": [
1526 |     "topfreq=L[:20]\n",
1527 |     "print topfreq\n",
1528 |     "pos = np.arange(len(topfreq))\n",
1529 |     "plt.bar(pos, [e[1] for e in topfreq]);\n",
1530 |     "plt.xticks(pos+0.4, [e[0] for e in topfreq]);"
1531 |    ]
1532 |   }
1533 |  ],
1534 |  "metadata": {
1535 |   "kernelspec": {
1536 |    "display_name": "Python 2",
1537 |    "language": "python",
1538 |    "name": "python2"
1539 |   },
1540 |   "language_info": {
1541 |    "codemirror_mode": {
1542 |     "name": "ipython",
1543 |     "version": 2
1544 |    },
1545 |    "file_extension": ".py",
1546 |    "mimetype": "text/x-python",
1547 |    "name": "python",
1548 |    "nbconvert_exporter": "python",
1549 |    "pygments_lexer": "ipython2",
1550 |    "version": "2.7.10"
1551 |   }
1552 |  },
1553 |  "nbformat": 4,
1554 |  "nbformat_minor": 0
1555 | }
1556 | 


--------------------------------------------------------------------------------