author | Prabhu Ramachandran <prabhu@aero.iitb.ac.in> |
Mon, 21 Jun 2010 00:49:03 -0400 | |
branch | scipy2010 |
changeset 412 | ca04d463c573 |
parent 389 | aa392117454f |
child 432 | 13e5d0e2cd40 |
permissions | -rw-r--r-- |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
2 |
% Tutorial slides on Python. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
3 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
4 |
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
5 |
% Copyright (c) 2005-2009, Prabhu Ramachandran |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
7 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
8 |
\documentclass[compress,14pt]{beamer} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
9 |
% \documentclass[handout]{beamer} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
10 |
% \usepackage{pgfpages} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
11 |
% \pgfpagesuselayout{4 on 1}[a4paper,border, shrink=5mm,landscape] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
12 |
\usepackage{tikz} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
13 |
\newcommand{\hyperlinkmovie}{} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
14 |
%\usepackage{movie15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
15 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
17 |
% Note that in presentation mode |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
18 |
% \paperwidth 364.19536pt |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
19 |
% \paperheight 273.14662pt |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
20 |
% h/w = 0.888 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
21 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
22 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
23 |
\mode<presentation> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
24 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
25 |
\usetheme{Warsaw} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
26 |
%\usetheme{Boadilla} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
27 |
%\usetheme{default} |
239
8953675dc056
Added slide numbers.
Puneeth Chaganti <punchagan@fossee.in>
parents:
220
diff
changeset
|
28 |
\useoutertheme{infolines} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
29 |
\setbeamercovered{transparent} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
30 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
31 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
32 |
% To remove navigation symbols |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
33 |
\setbeamertemplate{navigation symbols}{} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
34 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
35 |
\usepackage{amsmath} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
36 |
\usepackage[english]{babel} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
37 |
\usepackage[latin1]{inputenc} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
38 |
\usepackage{times} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
39 |
\usepackage[T1]{fontenc} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
40 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
41 |
% Taken from Fernando's slides. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
42 |
\usepackage{ae,aecompl} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
43 |
\usepackage{mathpazo,courier,euler} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
44 |
\usepackage[scaled=.95]{helvet} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
45 |
\usepackage{pgf} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
46 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
47 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
48 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
49 |
\usepackage{listings} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
50 |
\lstset{language=Python, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
51 |
basicstyle=\ttfamily\bfseries, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
52 |
commentstyle=\color{red}\itshape, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
53 |
stringstyle=\color{darkgreen}, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
54 |
showstringspaces=false, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
55 |
keywordstyle=\color{blue}\bfseries} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
56 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
57 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
58 |
% My Macros |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
59 |
\setbeamercolor{postit}{bg=yellow,fg=black} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
60 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
61 |
\newcommand{\emphbar}[1] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
62 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
63 |
{#1} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
64 |
\end{beamercolorbox} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
65 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
66 |
%{\centerline{\fcolorbox{gray!50} {blue!10}{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
67 |
%\begin{minipage}{0.9\linewidth} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
68 |
% {#1} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
69 |
%\end{minipage} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
70 |
% }}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
71 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
72 |
\newcommand{\myemph}[1]{\structure{\emph{#1}}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
73 |
\newcommand{\PythonCode}[1]{\lstinline{#1}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
74 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
75 |
\newcommand{\tvtk}{\texttt{tvtk}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
76 |
\newcommand{\mlab}{\texttt{mlab}} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
77 |
\newcommand{\typ}[1]{\lstinline{#1}} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
78 |
\newcounter{time} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
79 |
\setcounter{time}{0} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
80 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\vspace*{0.1in}\tiny \thetime\ m}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
81 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
82 |
\newcommand\BackgroundPicture[1]{% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
83 |
\setbeamertemplate{background}{% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
84 |
\parbox[c][\paperheight]{\paperwidth}{% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
85 |
\vfill \hfill |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
86 |
\hfill \vfill |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
87 |
}}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
88 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
89 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
90 |
% Configuring the theme |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
91 |
%\setbeamercolor{normal text}{fg=white} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
92 |
%\setbeamercolor{background canvas}{bg=black} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
93 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
94 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
95 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
96 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
97 |
% Title page |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
98 |
\title[Python Development]{Python Development} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
99 |
|
220
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
100 |
\author[FOSSEE] {FOSSEE} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
101 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
102 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
389
aa392117454f
Changed dates for MVIT workshop.
Puneeth Chaganti <punchagan@gmail.com>
parents:
385
diff
changeset
|
103 |
\date[] {1 May, 2010\\Day 2, Session 4} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
104 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
105 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
106 |
%\pgfdeclareimage[height=0.75cm]{iitblogo}{iitblogo} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
107 |
%\logo{\pgfuseimage{iitblogo}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
108 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
109 |
\AtBeginSection[] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
110 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
111 |
\begin{frame}<beamer> |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
112 |
\frametitle{Outline} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
113 |
\Large |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
114 |
\tableofcontents[currentsection,currentsubsection] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
115 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
116 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
117 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
118 |
%% Delete this, if you do not want the table of contents to pop up at |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
119 |
%% the beginning of each subsection: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
120 |
\AtBeginSubsection[] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
121 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
122 |
\begin{frame}<beamer> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
123 |
\frametitle{Outline} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
124 |
\tableofcontents[currentsection,currentsubsection] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
125 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
126 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
127 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
128 |
\AtBeginSection[] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
129 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
130 |
\begin{frame}<beamer> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
131 |
\frametitle{Outline} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
132 |
\tableofcontents[currentsection,currentsubsection] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
133 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
134 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
135 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
136 |
% DOCUMENT STARTS |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
137 |
\begin{document} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
138 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
139 |
\begin{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
140 |
\maketitle |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
141 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
142 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
143 |
\section{Tests: Getting started} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
144 |
\begin{frame}[fragile] |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
145 |
\frametitle{gcd revisited!} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
146 |
\begin{itemize} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
147 |
\item Open \texttt{gcd.py} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
148 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
149 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
150 |
def gcd(a, b): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
151 |
if a % b == 0: |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
152 |
return b |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
153 |
return gcd(b, a%b) |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
154 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
155 |
print gcd(15, 65) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
156 |
print gcd(16, 76) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
157 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
158 |
\begin{itemize} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
159 |
\item \texttt{python gcd.py} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
160 |
\end{itemize} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
161 |
\end{frame} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
162 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
163 |
\begin{frame}[fragile] |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
164 |
\frametitle{Find lcm using our gcd module} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
165 |
\begin{itemize} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
166 |
\item Open \texttt{lcm.py} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
167 |
\item $lcm = \frac{a * b}{gcd(a,b)}$ |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
168 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
169 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
170 |
from gcd import gcd |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
171 |
def lcm(a, b): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
172 |
return (a * b) / gcd(a, b) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
173 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
174 |
print lcm(14, 56) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
175 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
176 |
\begin{itemize} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
177 |
\item \texttt{python lcm.py} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
178 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
179 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
180 |
5 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
181 |
4 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
182 |
56 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
183 |
\end{lstlisting} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
184 |
\end{frame} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
185 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
186 |
\begin{frame}[fragile] |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
187 |
\frametitle{Writing stand-alone module} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
188 |
Edit \texttt{gcd.py} file to: |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
189 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
190 |
def gcd(a, b): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
191 |
if a % b == 0: |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
192 |
return b |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
193 |
return gcd(b, a%b) |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
194 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
195 |
if __name__ == "__main__": |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
196 |
print gcd(15, 65) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
197 |
print gcd(16, 76) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
198 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
199 |
\begin{itemize} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
200 |
\item \texttt{python gcd.py} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
201 |
\item \texttt{python lcm.py} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
202 |
\end{itemize} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
203 |
\end{frame} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
204 |
|
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
205 |
\begin{frame}[fragile] |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
206 |
\frametitle{Automating tests} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
207 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
208 |
if __name__ == '__main__': |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
209 |
for line in open('numbers.txt'): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
210 |
numbers = line.split() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
211 |
x = int(numbers[0]) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
212 |
y = int(numbers[1]) |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
213 |
result = int(numbers[2]) |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
214 |
if gcd(x, y) != result: |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
215 |
print "Failed gcd test |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
216 |
for", x, y |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
217 |
\end{lstlisting} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
218 |
\end{frame} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
219 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
220 |
\section{Coding Style} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
221 |
\begin{frame}{Readability and Consistency} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
222 |
\begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
223 |
\item Readability Counts!\\Code is read more often than its written. |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
224 |
\item Consistency! |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
225 |
\item Know when to be inconsistent. |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
226 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
227 |
\end{frame} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
228 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
229 |
\begin{frame}[fragile] \frametitle{A question of good style} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
230 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
231 |
amount = 12.68 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
232 |
denom = 0.05 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
233 |
nCoins = round(amount/denom) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
234 |
rAmount = nCoins * denom |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
235 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
236 |
\pause |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
237 |
\begin{block}{Style Rule \#1} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
238 |
Naming is 80\% of programming |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
239 |
\end{block} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
240 |
\end{frame} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
241 |
|
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
242 |
\begin{frame}[fragile] |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
243 |
\frametitle{Code Layout} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
244 |
\begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
245 |
\item Indentation |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
246 |
\item Tabs or Spaces? |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
247 |
\item Maximum Line Length |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
248 |
\item Blank Lines |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
249 |
\item Encodings |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
250 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
251 |
\end{frame} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
252 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
253 |
\begin{frame}{Whitespaces in Expressions} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
254 |
\begin{itemize} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
255 |
\item When to use extraneous whitespaces? |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
256 |
\item When to avoid extra whitespaces? |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
257 |
\item Use one statement per line |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
258 |
\end{itemize} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
259 |
\end{frame} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
260 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
261 |
\begin{frame}{Comments} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
262 |
\begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
263 |
\item No comments better than contradicting comments |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
264 |
\item Block comments |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
265 |
\item Inline comments |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
266 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
267 |
\end{frame} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
268 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
269 |
\begin{frame}{Docstrings} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
270 |
\begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
271 |
\item When to write docstrings? |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
272 |
\item Ending the docstrings |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
273 |
\item One liner docstrings |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
274 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
275 |
More information at PEP8: http://www.python.org/dev/peps/pep-0008/ |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
276 |
\inctime{5} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
277 |
\end{frame} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
278 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
279 |
\section{Debugging} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
280 |
\subsection{Errors and Exceptions} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
281 |
\begin{frame}[fragile] |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
282 |
\frametitle{Errors} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
283 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
284 |
In []: while True print 'Hello world' |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
285 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
286 |
\pause |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
287 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
288 |
File "<stdin>", line 1, in ? |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
289 |
while True print 'Hello world' |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
290 |
^ |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
291 |
SyntaxError: invalid syntax |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
292 |
\end{lstlisting} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
293 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
294 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
295 |
\begin{frame}[fragile] |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
296 |
\frametitle{Exceptions} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
297 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
298 |
In []: print spam |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
299 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
300 |
\pause |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
301 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
302 |
Traceback (most recent call last): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
303 |
File "<stdin>", line 1, in <module> |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
304 |
NameError: name 'spam' is not defined |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
305 |
\end{lstlisting} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
306 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
307 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
308 |
\begin{frame}[fragile] |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
309 |
\frametitle{Exceptions} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
310 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
311 |
In []: 1 / 0 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
312 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
313 |
\pause |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
314 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
315 |
Traceback (most recent call last): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
316 |
File "<stdin>", line 1, in <module> |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
317 |
ZeroDivisionError: integer division |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
318 |
or modulo by zero |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
319 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
320 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
321 |
|
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
322 |
\begin{frame}[fragile] |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
323 |
\frametitle{Processing user input} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
324 |
\begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
325 |
prompt = 'Enter a number(Q to quit): ' |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
326 |
|
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
327 |
a = raw_input(prompt) |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
328 |
|
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
329 |
num = int(a) if a != 'Q' else 0 |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
330 |
\end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
331 |
\emphbar{What if the user enters some other alphabet?} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
332 |
\end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
333 |
|
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
334 |
|
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
335 |
\begin{frame}[fragile] |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
336 |
\frametitle{Handling Exceptions} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
337 |
Python provides \typ{try} and \typ{except} clause. |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
338 |
\begin{lstlisting} |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
339 |
prompt = 'Enter a number(Q to quit): ' |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
340 |
|
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
341 |
a = raw_input(prompt) |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
342 |
try: |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
343 |
num = int(a) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
344 |
print num |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
345 |
except: |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
346 |
if a == 'Q': |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
347 |
print "Exiting ..." |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
348 |
else: |
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
349 |
print "Wrong input ..." |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
350 |
\end{lstlisting} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
351 |
\end{frame} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
256
diff
changeset
|
352 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
353 |
\subsection{Strategy} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
354 |
\begin{frame}[fragile] |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
355 |
\frametitle{Debugging effectively} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
356 |
\begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
357 |
\item \typ{print} based strategy |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
358 |
\item Process: |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
359 |
\end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
360 |
\begin{center} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
361 |
\pgfimage[interpolate=true,width=5cm,height=5cm]{DebugginDiagram.png} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
362 |
\end{center} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
363 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
364 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
365 |
\begin{frame}[fragile] |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
366 |
\frametitle{Debugging effectively} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
367 |
\begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
368 |
\item Using \typ{\%debug} in IPython |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
369 |
\end{itemize} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
370 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
371 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
372 |
\begin{frame}[fragile] |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
373 |
\frametitle{Debugging in IPython} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
374 |
\small |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
375 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
376 |
In []: import mymodule |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
377 |
In []: mymodule.test() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
378 |
--------------------------------------------- |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
379 |
NameError Traceback (most recent call last) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
380 |
<ipython console> in <module>() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
381 |
mymodule.py in test() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
382 |
1 def test(): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
383 |
----> 2 print spam |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
384 |
NameError: global name 'spam' is not defined |
288
c4e25269a86c
Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
263
diff
changeset
|
385 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
386 |
In []: %debug |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
387 |
> mymodule.py(2)test() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
388 |
0 print spam |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
389 |
ipdb> |
288
c4e25269a86c
Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
263
diff
changeset
|
390 |
\end{lstlisting} |
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
391 |
\inctime{15} |
288
c4e25269a86c
Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
263
diff
changeset
|
392 |
\end{frame} |
c4e25269a86c
Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
263
diff
changeset
|
393 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
394 |
\subsection{Exercise} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
395 |
\begin{frame}[fragile] |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
396 |
\frametitle{Debugging: Exercise} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
397 |
\small |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
398 |
\begin{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
399 |
science = {} |
288
c4e25269a86c
Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
263
diff
changeset
|
400 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
401 |
for record in open('sslc1.txt'): |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
402 |
fields = record.split(';') |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
403 |
region_code = fields[0].strip() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
404 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
405 |
score_str = fields[6].strip() |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
406 |
score = int(score_str) if score_str != 'AA' |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
407 |
else 0 |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
408 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
409 |
if score > 90: |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
410 |
science[region_code] += 1 |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
411 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
412 |
pie(science.values(), labels=science.keys()) |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
413 |
savefig('science.png') |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
414 |
\end{lstlisting} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
415 |
\inctime{10} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
416 |
\end{frame} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
417 |
|
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
418 |
\begin{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
419 |
\frametitle{Summary} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
420 |
We have covered: |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
421 |
\begin{itemize} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
422 |
\item Following and Resolving Error Messages. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
423 |
\item Exceptions. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
424 |
\item Handling exceptions |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
425 |
\item Approach for Debugging. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
426 |
% \item Writting and running tests. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
427 |
\end{itemize} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
428 |
\end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
429 |
|
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
430 |
\end{document} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
431 |
|
344
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
432 |
%% \begin{frame}[fragile] |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
433 |
%% \frametitle{\incqno} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
434 |
%% Consider a module called \lstinline+gcd.py+ looking like this: |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
435 |
%% \begin{lstlisting} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
436 |
%% def gcd(a, b): |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
437 |
%% ... |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
438 |
|
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
439 |
%% if __name__ == '__main__': |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
440 |
%% print gcd(10, 25) |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
441 |
%% \end{lstlisting} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
442 |
%% If this module is imported, will it print the gcd of 10 and 25? |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
443 |
%% \end{frame} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
444 |
|
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
445 |
%% \begin{frame}[fragile] |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
446 |
%% \frametitle{\incqno} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
447 |
%% \begin{lstlisting} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
448 |
%% In [1]: print hello |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
449 |
%% \end{lstlisting} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
450 |
%% Exactly what exception will you get if you run this on a fresh |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
451 |
%% interpreter? |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
452 |
%% \end{frame} |
19754ed6050f
Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
339
diff
changeset
|
453 |
|
289
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
454 |
%% \begin{frame} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
455 |
%% \frametitle{Testing} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
456 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
457 |
%% \begin{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
458 |
%% \item Writing tests is really simple! |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
459 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
460 |
%% \item Using nose. |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
461 |
|
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
462 |
%% \item Example! |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
463 |
%% \end{itemize} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
464 |
%% \end{frame} |
884d42eff66d
Reorganized last 3 sessions of day 2 again.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
288
diff
changeset
|
465 |
|
297
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
466 |
% \section{Test Driven Approach} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
467 |
% \begin{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
468 |
% \frametitle{Need for Testing!} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
469 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
470 |
% \begin{itemize} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
471 |
% \item Quality |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
472 |
% \item Regression |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
473 |
% \item Documentation |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
474 |
% \end{itemize} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
475 |
% %% \vspace*{0.25in} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
476 |
% %% \emphbar{It is to assure that section of code is working as it is supposed to work} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
477 |
% \end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
478 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
479 |
% \begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
480 |
% \frametitle{Example} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
481 |
% \begin{block}{Problem Statement} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
482 |
% Write a function to check whether a given input |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
483 |
% string is a palindrome. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
484 |
% \end{block} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
485 |
% \end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
486 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
487 |
% \begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
488 |
% \frametitle{Function: palindrome.py} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
489 |
% \begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
490 |
% def is_palindrome(input_str): |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
491 |
% return input_str == input_str[::-1] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
492 |
% \end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
493 |
% \end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
494 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
495 |
% \begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
496 |
% \frametitle{Test for the palindrome: palindrome.py} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
497 |
% \begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
498 |
% def test_function_normal_words(): |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
499 |
% input = "noon" |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
500 |
% assert is_palindrome(input) == True |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
501 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
502 |
% if __name__ == "main'': |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
503 |
% test_function_normal_words() |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
504 |
% \end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
505 |
% \end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
506 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
507 |
% \begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
508 |
% \frametitle{Running the tests.} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
509 |
% \begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
510 |
% $ nosetests palindrome.py |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
511 |
% . |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
512 |
% ---------------------------------------------- |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
513 |
% Ran 1 test in 0.001s |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
514 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
515 |
% OK |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
516 |
% \end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
517 |
% \end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
518 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
519 |
% \begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
520 |
% \frametitle{Exercise: Including new tests.} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
521 |
% \begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
522 |
% def test_function_ignore_cases_words(): |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
523 |
% input = "Noon" |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
524 |
% assert is_palindrome(input) == True |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
525 |
% \end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
526 |
% \vspace*{0.25in} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
527 |
% Check\\ |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
528 |
% \PythonCode{$ nosetests palindrome.py} \\ |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
529 |
% \begin{block}{Task} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
530 |
% Tweak the code to pass this test. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
531 |
% \end{block} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
532 |
% \end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
533 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
534 |
% %\begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
535 |
% % \frametitle{Lets write some test!} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
536 |
% %\begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
537 |
% %#for form of equation y=mx+c |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
538 |
% %#given m and c for two equation, |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
539 |
% %#finding the intersection point. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
540 |
% %def intersect(m1,c1,m2,c2): |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
541 |
% % x = (c2-c1)/(m1-m2) |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
542 |
% % y = m1*x+c1 |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
543 |
% % return (x,y) |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
544 |
% %\end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
545 |
% % |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
546 |
% %Create a simple test for this |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
547 |
% % |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
548 |
% %function which will make it fail. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
549 |
% % |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
550 |
% %\inctime{15} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
551 |
% %\end{frame} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
552 |
% % |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
553 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
554 |
% %% \begin{frame}[fragile] |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
555 |
% %% \frametitle{Exercise} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
556 |
% %% Based on Euclid's algorithm: |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
557 |
% %% \begin{center} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
558 |
% %% $gcd(a,b)=gcd(b,b\%a)$ |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
559 |
% %% \end{center} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
560 |
% %% gcd function can be written as: |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
561 |
% %% \begin{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
562 |
% %% def gcd(a, b): |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
563 |
% %% if a%b == 0: return b |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
564 |
% %% return gcd(b, a%b) |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
565 |
% %% \end{lstlisting} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
566 |
% %% \vspace*{-0.15in} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
567 |
% %% \begin{block}{Task} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
568 |
% %% \begin{itemize} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
569 |
% %% \item Write at least |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
570 |
% %% two tests for above mentioned function. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
571 |
% %% \item Write a non recursive implementation |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
572 |
% %% of gcd(), and test it using already |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
573 |
% %% written tests. |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
574 |
% %% \end{itemize} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
575 |
% %% \end{block} |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
576 |
% |
a835affb1447
Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
289
diff
changeset
|
577 |
% %% \inctime{15} |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
297
diff
changeset
|
578 |
% %% \end{frame} |