author | Puneeth Chaganti <punchagan@fossee.in> |
Tue, 06 Oct 2009 18:30:44 +0530 | |
changeset 40 | a2597c20c669 |
parent 29 | 8121d3ea15b5 |
child 45 | 3b8be02d94d4 |
permissions | -rwxr-xr-x |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
% Tutorial slides on Python. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
% Copyright (c) 2005-2008, Prabhu Ramachandran |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
\documentclass[14pt,compress]{beamer} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
%\documentclass[draft]{beamer} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
%\documentclass[compress,handout]{beamer} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
%\usepackage{pgfpages} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
% Modified from: generic-ornate-15min-45min.de.tex |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
\mode<presentation> |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
{ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
\usetheme{Warsaw} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
\useoutertheme{split} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
\setbeamercovered{transparent} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
\usepackage[english]{babel} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
\usepackage[latin1]{inputenc} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
%\usepackage{times} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
\usepackage[T1]{fontenc} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
% Taken from Fernando's slides. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
\usepackage{ae,aecompl} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
29 |
\usepackage{mathpazo,courier,euler} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
30 |
\usepackage[scaled=.95]{helvet} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
31 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
32 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
\usepackage{listings} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
\lstset{language=Python, |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
36 |
basicstyle=\ttfamily\bfseries, |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |
commentstyle=\color{red}\itshape, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
38 |
stringstyle=\color{darkgreen}, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
39 |
showstringspaces=false, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
keywordstyle=\color{blue}\bfseries} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
41 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
% Macros |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
44 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
45 |
\newcommand{\emphbar}[1] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
46 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
47 |
{#1} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
48 |
\end{beamercolorbox} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
49 |
} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
50 |
\newcounter{time} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
51 |
\setcounter{time}{0} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
52 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
53 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
54 |
\newcommand{\typ}[1]{\texttt{#1}} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
55 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
56 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
57 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
58 |
%%% This is from Fernando's setup. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
59 |
% \usepackage{color} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
60 |
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
61 |
% % Use and configure listings package for nicely formatted code |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
62 |
% \usepackage{listings} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
63 |
% \lstset{ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
64 |
% language=Python, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
65 |
% basicstyle=\small\ttfamily, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
66 |
% commentstyle=\ttfamily\color{blue}, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
67 |
% stringstyle=\ttfamily\color{orange}, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
68 |
% showstringspaces=false, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
69 |
% breaklines=true, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
70 |
% postbreak = \space\dots |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
71 |
% } |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
72 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
73 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
75 |
% Title page |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
76 |
\title[Basic Python]{Python:\\A great programming toolkit} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
77 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
78 |
\author[Asokan \& Prabhu] {Asokan Pichai\\Prabhu Ramachandran} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
79 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
80 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
81 |
\date[] {10, October 2009} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
82 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
83 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
84 |
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
85 |
%\logo{\pgfuseimage{iitmlogo}} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
86 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
87 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
88 |
%% Delete this, if you do not want the table of contents to pop up at |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
89 |
%% the beginning of each subsection: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
90 |
\AtBeginSubsection[] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
91 |
{ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
92 |
\begin{frame}<beamer> |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
93 |
\frametitle{Outline} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
94 |
\tableofcontents[currentsection,currentsubsection] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
95 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
96 |
} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
97 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
98 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
99 |
% If you wish to uncover everything in a step-wise fashion, uncomment |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
100 |
% the following command: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
101 |
%\beamerdefaultoverlayspecification{<+->} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
102 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
103 |
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
104 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
106 |
% DOCUMENT STARTS |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
107 |
\begin{document} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
108 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
109 |
\begin{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
110 |
\titlepage |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
111 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
112 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
113 |
\section{Python} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
114 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
115 |
\subsection{Dictionary} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
116 |
\begin{frame}{Dictionary} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
117 |
\begin{itemize} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
118 |
\item aka associative arrays, key-value pairs, hashmaps, hashtables \ldots |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
119 |
\item \typ{ d = \{ ``Hitchhiker's guide'' : 42, ``Terminator'' : ``I'll be back''\}} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
120 |
\item lists and tuples index: 0 \ldots n |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
121 |
\item dictionaries index using strings |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
122 |
\item aka key-value pairs |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
123 |
\item what can be keys? |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
124 |
\end{itemize} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
125 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
126 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
127 |
\begin{frame}{Dictionary \ldots } |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
128 |
\begin{itemize} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
129 |
\item \alert{Unordered} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
130 |
\begin{block}{Standard usage} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
131 |
for key in dict:\\ |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
132 |
<use> dict[key] \# => value |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
133 |
\end{block} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
134 |
\item \typ{d.keys()} returns a list |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
135 |
\item can we have duplicate keys? |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
136 |
\end{itemize} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
137 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
138 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
139 |
\begin{frame} {Problem Set 2.1} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
140 |
\begin{description} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
141 |
\item[2.1.1] You are given date strings of the form ``29, Jul 2009'', or ``4 January 2008''. In other words a number a string and another number, with a comma sometimes separating the items.Write a function that takes such a string and returns a tuple (yyyy, mm, dd) where all three elements are ints. |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
142 |
\item[2.1.2] Count word frequencies in a file. |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
143 |
\item[2.1.3] Find the most used Python keywords in your Python code (import keyword). |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
144 |
\end{description} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
145 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
146 |
\inctime{20} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
147 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
148 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
149 |
\subsection{Set} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
150 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
151 |
\frametitle{Set} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
152 |
\begin{itemize} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
153 |
\item Simplest container, mutable |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
154 |
\item No ordering, no duplicates |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
155 |
\item usual suspects: union, intersection, subset \ldots |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
156 |
\item >, >=, <, <=, in, \ldots |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
157 |
\end{itemize} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
158 |
\begin{lstlisting} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
159 |
>>> f10 = set([1,2,3,5,8]) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
160 |
>>> p10 = set([2,3,5,7]) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
161 |
>>> f10|p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
162 |
set([1, 2, 3, 5, 7, 8]) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
163 |
>>> f10&p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
164 |
set([2, 3, 5]) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
165 |
>>> f10-p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
166 |
set([8, 1]) |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
167 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
168 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
169 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
170 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
171 |
\frametitle{Set} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
172 |
\begin{lstlisting} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
173 |
>>> p10-f10, f10^p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
174 |
set([7]), set([1, 7, 8]) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
175 |
>>> set([2,3]) < p10 |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
176 |
True |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
177 |
>>> set([2,3]) <= p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
178 |
True |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
179 |
>>> 2 in p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
180 |
True |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
181 |
>>> 4 in p10 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
182 |
False |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
183 |
>>> len(f10) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
184 |
5 |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
185 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
186 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
187 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
188 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
189 |
\begin{frame} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
190 |
\frametitle{Problem set 2.2} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
191 |
\begin{description} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
192 |
\item[2.2.1] Given a dictionary of the names of students and their marks, identify how many duplicate marks are there? and what are these? |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
193 |
\item[2.2.2] Given a string of the form ``4-7, 9, 12, 15'' find the numbers missing in this list for a given range. |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
194 |
\end{description} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
195 |
\inctime{15} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
196 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
197 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
198 |
\subsection{Functions Reloaded!} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
199 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
200 |
\frametitle{Advanced functions} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
201 |
\begin{itemize} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
202 |
\item default args |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
203 |
\item var args |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
204 |
\item keyword args |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
205 |
\item scope |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
206 |
\item \typ{global} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
207 |
\end{itemize} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
208 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
209 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
210 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
211 |
\frametitle{Functions: default arguments} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
212 |
\small |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
213 |
\begin{lstlisting} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
214 |
def ask_ok(prompt, retries=4, |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
215 |
complaint='Yes or no!'): |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
216 |
while True: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
217 |
ok = raw_input(prompt) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
218 |
if ok in ('y', 'ye', 'yes'): |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
219 |
return True |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
220 |
if ok in ('n', 'no', 'nop', |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
221 |
'nope'): |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
222 |
return False |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
223 |
retries = retries - 1 |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
224 |
if retries < 0: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
225 |
raise IOError, 'bad user' |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
226 |
print complaint |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
227 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
228 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
229 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
230 |
\begin{frame}[fragile] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
231 |
\frametitle{Functions: keyword arguments} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
232 |
\small |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
233 |
\begin{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
234 |
def parrot(voltage, state='a stiff', |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
235 |
action='voom', type='Royal Blue'): |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
236 |
print "-- This parrot wouldn't", action, |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
237 |
print "if you supply", voltage, "Volts." |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
238 |
print "-- Lovely plumage, the", type |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
239 |
print "-- It's", state, "!" |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
240 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
241 |
parrot(1000) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
242 |
parrot(action = 'VOOOOOM', voltage = 1000000) |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
243 |
parrot('a thousand', |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
244 |
state = 'pushing up the daisies') |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
245 |
parrot('a million', 'bereft of life', 'jump') |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
246 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
247 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
248 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
249 |
\begin{frame}[fragile] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
250 |
\frametitle{Functions: arbitrary argument lists} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
251 |
\begin{itemize} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
252 |
\item Arbitrary number of arguments using \verb+*args+ or |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
253 |
\verb+*whatever+ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
254 |
\item Keyword arguments using \verb+**kw+ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
255 |
\item Given a tuple/dict how do you call a function? |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
256 |
\begin{itemize} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
257 |
\item Using argument unpacking |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
258 |
\item For positional arguments: \verb+foo(*[5, 10])+ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
259 |
\item For keyword args: \verb+foo(**{'a':5, 'b':10})+ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
260 |
\end{itemize} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
261 |
\end{itemize} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
262 |
\end{frame} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
263 |
|
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
264 |
\begin{frame}[fragile] |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
265 |
\begin{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
266 |
def foo(a=10, b=100): |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
267 |
print a, b |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
268 |
def func(*args, **keyword): |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
269 |
print args, keyword |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
270 |
# Unpacking: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
271 |
args = [5, 10] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
272 |
foo(*args) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
273 |
kw = {'a':5, 'b':10} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
274 |
foo(**kw) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
275 |
\end{lstlisting} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
276 |
\inctime{15} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
277 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
278 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
279 |
\subsection{Functional programming} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
280 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
281 |
\frametitle{Functional programming} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
282 |
What is the basic idea?\\ |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
283 |
Why is it interesting?\\ |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
284 |
\typ{map, reduce, filter}\\ |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
285 |
list comprehension\\ |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
286 |
generators |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
287 |
\inctime{10} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
288 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
289 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
290 |
\subsection{Debugging} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
291 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
292 |
\frametitle{Errors} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
293 |
\begin{lstlisting} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
294 |
>>> while True print 'Hello world' |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
295 |
File "<stdin>", line 1, in ? |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
296 |
while True print 'Hello world' |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
297 |
^ |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
298 |
SyntaxError: invalid syntax |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
299 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
300 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
301 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
302 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
303 |
\frametitle{Exceptions} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
304 |
\begin{lstlisting} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
305 |
>>> print spam |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
306 |
Traceback (most recent call last): |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
307 |
File "<stdin>", line 1, in <module> |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
308 |
NameError: name 'spam' is not defined |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
309 |
|
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
310 |
>>> 1 / 0 |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
311 |
Traceback (most recent call last): |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
312 |
File "<stdin>", line 1, in <module> |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
313 |
ZeroDivisionError: integer division |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
314 |
or modulo by zero |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
315 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
316 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
317 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
318 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
319 |
\frametitle{Debugging effectively} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
320 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
321 |
\begin{itemize} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
322 |
\item \kwrd{print} based strategy |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
323 |
\item Process: Hypothesis, test, refine, rinse-repeat |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
324 |
\item Using \typ{\%debug} and \typ{\%pdb} in IPython |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
325 |
\end{itemize} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
326 |
\inctime{10} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
327 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
328 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
329 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
330 |
\frametitle{Debugging: example} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
331 |
\small |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
332 |
\begin{lstlisting} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
333 |
>>> import pdb |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
334 |
>>> import mymodule |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
335 |
>>> pdb.run('mymodule.test()') |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
336 |
> <string>(1)<module>() |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
337 |
(Pdb) continue |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
338 |
Traceback (most recent call last): |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
339 |
File "<stdin>", line 1, in <module> |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
340 |
File "/usr/lib/python2.6/pdb.py", line 1207, in run |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
341 |
Pdb().run(statement, globals, locals) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
342 |
File "/usr/lib/python2.6/bdb.py", line 368, in run |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
343 |
exec cmd in globals, locals |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
344 |
File "<string>", line 1, in <module> |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
345 |
File "mymodule.py", line 2, in test |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
346 |
print spam |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
347 |
NameError: global name 'spam' is not defined |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
348 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
349 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
350 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
351 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
352 |
\frametitle{Debugging in IPython} |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
353 |
\small |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
354 |
\begin{lstlisting} |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
355 |
In [1]: %pdb |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
356 |
Automatic pdb calling has been turned ON |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
357 |
In [2]: import mymodule |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
358 |
In [3]: mymodule.test() |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
359 |
---------------------------------------------- |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
360 |
NameError Traceback (most recent call last) |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
361 |
/media/python/iitb/workshops/day1/<ipython console> in <module>() |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
362 |
/media/python/iitb/workshops/day1/mymodule.pyc in test() |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
363 |
1 def test(): |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
364 |
----> 2 print spam |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
365 |
NameError: global name 'spam' is not defined |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
366 |
> /media/python/iitb/workshops/day1/mymodule.py(2)test() |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
367 |
0 print spam |
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
368 |
ipdb> |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
369 |
\end{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
370 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
371 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
372 |
\begin{frame}[fragile] |
29
8121d3ea15b5
Completed slides for session 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
5
diff
changeset
|
373 |
\frametitle{Debugging: Exercise} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
374 |
\end{frame} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
375 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
376 |
\end{document} |