author | Madhusudan.C.S <madhusudancs@gmail.com> |
Fri, 09 Oct 2009 13:20:23 +0530 | |
changeset 88 | b040a84de1cc |
parent 79 | 04b620d3f172 |
child 106 | 7b539cba0f04 |
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> |
46
63704b5650f1
Changed the copyright and Institute for all the sessions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
42
diff
changeset
|
5 |
% Copyright (c) 2005-2009, Prabhu Ramachandran |
5
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, |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
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 |
46
63704b5650f1
Changed the copyright and Institute for all the sessions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
42
diff
changeset
|
76 |
\title[Basic Python]{Python:\\Modular Code, Handling Files and Objects} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
77 |
|
46
63704b5650f1
Changed the copyright and Institute for all the sessions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
42
diff
changeset
|
78 |
\author[FOSSEE Team] {Asokan Pichai\\Prabhu Ramachandran} |
5
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} |
49
2adb90f9e287
Added what did we learn to all slides and reworked on Session 2 and 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
48
diff
changeset
|
81 |
\date[] {10, October 2009\\Day 1, Session 3} |
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 |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
89 |
%% the beginning of each section: |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
90 |
\AtBeginSection[] |
5
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} |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
94 |
\tableofcontents[currentsection] |
5
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 |
|
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
113 |
\section{\typ{for}, Lists and Tuples} |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
114 |
|
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
115 |
\begin{frame}{Quick Recap} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
116 |
\begin{itemize} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
117 |
\item List indexing and slicing |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
118 |
\item The \kwrd{range()} function |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
119 |
\item \kwrd{for} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
120 |
\item Iterating lists and tuples using \kwrd{for} and \kwrd{range()} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
121 |
\end{itemize} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
122 |
\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
|
123 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
124 |
\begin{frame}{Problem 3.1} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
125 |
Which of the earlier problems is simpler when we use \kwrd{for} instead of \kwrd{while}? |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
126 |
\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
|
127 |
|
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{frame}{Problem 3.2} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
129 |
Given an empty chessboard and one Bishop placed in any square, say (r, c), generate the list of all squares the Bishop could move to. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
130 |
\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
|
131 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
132 |
\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
|
133 |
\frametitle{Problem 3.3} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
134 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
135 |
Given two real numbers \typ{a, b}, and an integer \typ{N}, write a |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
136 |
function named \typ{linspace( a, b, N)} that returns an ordered list |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
137 |
of \typ{N} points starting with \typ{a} and ending in \typ{b} and |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
138 |
equally spaced.\\ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
139 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
140 |
For example, \typ{linspace(0, 5, 11)}, should return, \\ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
141 |
\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
|
142 |
[ 0.0 , 0.5, 1.0 , 1.5, 2.0 , 2.5, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
143 |
3.0 , 3.5, 4.0 , 4.5, 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
|
144 |
\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
|
145 |
\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
|
146 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
147 |
\begin{frame}[fragile] |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
148 |
\frametitle{Problem 3.4} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
149 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
150 |
Use the \typ{linspace} function and generate a list of N tuples of the form\\ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
151 |
\typ{[($x_1$,f($x_1$)),($x_2$,f($x_2$)),\ldots,($x_N$,f($x_N$))]}\\for the following functions,\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
|
152 |
\item \typ{f(x) = sin(x)} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
153 |
\item \typ{f(x) = sin(x) + sin(10*x)}. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
154 |
\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
|
155 |
\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
|
156 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
157 |
\begin{frame}[fragile] |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
158 |
\frametitle{Problem 3.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
|
159 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
160 |
Using the tuples generated earlier, determine the intervals where the roots of the functions lie. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
161 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
162 |
\inctime{15} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
163 |
\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
|
164 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
165 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
166 |
% TIME: 15 m, running 185m |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
167 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
168 |
|
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
169 |
\section{Parsing} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
170 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
171 |
\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
|
172 |
\frametitle{Simple tokenizing and parsing} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
173 |
\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
|
174 |
s = """The quick brown fox jumped |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
175 |
over the lazy dog""" |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
176 |
for word in s.split(): |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
177 |
print word.capitalize() |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
178 |
\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
|
179 |
\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
|
180 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
181 |
\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
|
182 |
\frametitle{Problem 4.1} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
183 |
Given a string like, ``1, 3-7, 12, 15, 18-21'', produce the list \\ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
184 |
\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
|
185 |
[1,3,4,5,6,7,12,15,18,19,20,21] |
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{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
187 |
\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
|
188 |
|
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
189 |
\section{Input/Output} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
190 |
|
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
191 |
\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
|
192 |
\frametitle{File handling} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
193 |
\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
|
194 |
>>> f = open('/path/to/file_name') |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
195 |
>>> data = f.read() # Read entire file. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
196 |
>>> line = f.readline() # Read one line. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
197 |
>>> f.close() # close the file. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
198 |
\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
|
199 |
Writing files |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
200 |
\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
|
201 |
>>> f = open('/path/to/file_name', 'w') |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
202 |
>>> f.write('hello world\n') |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
203 |
>>> f.close() |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
204 |
\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
|
205 |
\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
|
206 |
\item Everything read or written is a string |
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 |
\emphbar{Try \typ{file?} for more help} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
209 |
\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
|
210 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
211 |
\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
|
212 |
\frametitle{File and \kwrd{for}} |
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} |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
214 |
$ cat dummyfile |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
215 |
One 1 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
216 |
Two 2 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
217 |
Three 3 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
218 |
Four 4 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
219 |
Five 5 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
220 |
Six 6 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
221 |
Seven 7 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
222 |
Eight 8 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
223 |
Nine 9 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
224 |
Ten 10 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
225 |
\end{lstlisting} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
226 |
\end{frame} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
227 |
|
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
228 |
\begin{frame}[fragile] |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
229 |
\frametitle{File and \kwrd{for}} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
230 |
\begin{lstlisting} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
231 |
>>> f = open('dummyfile') |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
232 |
>>> for line in f: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
233 |
... print line |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
234 |
... |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
235 |
\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
|
236 |
\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
|
237 |
|
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
238 |
\begin{frame}[fragile] |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
239 |
\frametitle{File and \kwrd{for}} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
240 |
\begin{lstlisting} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
241 |
In [1]: f = open('dummyfile') |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
242 |
|
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
243 |
In [2]: for line in f: |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
244 |
...: print line |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
245 |
...: |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
246 |
\end{lstlisting} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
247 |
|
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
248 |
\begin{columns} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
249 |
\column{0.3\textwidth} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
250 |
|
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
251 |
\begin{lstlisting} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
252 |
One 1 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
253 |
|
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
254 |
Two 2 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
255 |
|
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
256 |
Three 3 |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
257 |
\end{lstlisting} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
258 |
\column{0.6\textwidth} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
259 |
\pause |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
260 |
\begin{block}{What happens when ...} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
261 |
the \kwrd{print line} is replaced by \kwrd{print line,} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
262 |
\end{block} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
263 |
\end{columns} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
264 |
\ldots |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
265 |
\end{frame} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
266 |
|
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
267 |
\begin{frame}{Problem 4.2} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
268 |
The given file has lakhs of records in the form:\\ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
269 |
\typ{RGN;ID;NAME;MARK1;\ldots;MARK5;TOTAL;PFW}\\ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
270 |
Some entries may be empty. Read the data from this file and print the |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
271 |
name of the student with the maximum total marks. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
272 |
\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
|
273 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
274 |
\begin{frame}{Problem 4.3} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
275 |
For the same data file compute the average marks in different |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
276 |
subjects, the student with the maximum mark in each subject and also |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
277 |
the standard deviation of the marks. Do this efficiently. |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
278 |
|
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
279 |
\inctime{30} |
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 |
\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
|
281 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
282 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
283 |
% TIME: 30 m, running 215m |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
284 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
285 |
|
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
286 |
\section{Modules} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
287 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
288 |
\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
|
289 |
{Modules} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
290 |
\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
|
291 |
>>> sqrt(2) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
292 |
Traceback (most recent call last): |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
293 |
File "<stdin>", line 1, in <module> |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
294 |
NameError: name 'sqrt' is not defined |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
295 |
>>> import math |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
296 |
>>> math.sqrt(2) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
297 |
1.4142135623730951 |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
298 |
\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
|
299 |
\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
|
300 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
301 |
\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
|
302 |
{Modules} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
303 |
\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
|
304 |
\item The \kwrd{import} keyword ``loads'' a module |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
305 |
\item One can also use: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
306 |
\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
|
307 |
>>> from math import sqrt |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
308 |
>>> from math import * |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
309 |
\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
|
310 |
\item What is the difference? |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
311 |
\item \alert{Use the later only in interactive mode} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
312 |
\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
|
313 |
\emphbar{Package hierarchies} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
314 |
\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
|
315 |
>>> from os.path import exists |
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{lstlisting} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
317 |
\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
|
318 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
319 |
\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
|
320 |
\frametitle{Modules: Standard library} |
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} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
322 |
\item Very powerful, ``Batteries included'' |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
323 |
\item Some standard modules: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
324 |
\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
|
325 |
\item Math: \typ{math}, \typ{random} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
326 |
\item Internet access: \typ{urllib2}, \typ{smtplib} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
327 |
\item System, Command line arguments: \typ{sys} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
328 |
\item Operating system interface: \typ{os} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
329 |
\item Regular expressions: \typ{re} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
330 |
\item Compression: \typ{gzip}, \typ{zipfile}, and \typ{tarfile} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
331 |
\item And a whole lot more! |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
332 |
\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
|
333 |
\item Check out the Python Library reference: |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
334 |
\url{http://docs.python.org/library/} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
335 |
\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
|
336 |
\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
|
337 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
338 |
\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
|
339 |
{Modules of special interest} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
340 |
\begin{description}[matplotlibfor2d] |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
341 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
342 |
\item[\typ{numpy}] Efficient, powerful numeric arrays |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
343 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
344 |
\item[\typ{matplotlib}] Easy, interactive, 2D plotting |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
345 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
346 |
\item[\typ{scipy}] statistics, optimization, integration, linear |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
347 |
algebra, Fourier transforms, signal and image processing, |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
348 |
genetic algorithms, ODE solvers, special functions, and more |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
349 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
350 |
\item[Mayavi] Easy, interactive, 3D plotting |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
351 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
352 |
\end{description} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
353 |
\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
|
354 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
355 |
\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
|
356 |
{Creating your own modules} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
357 |
\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
|
358 |
\item Define variables, functions and classes in a file with a |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
359 |
\typ{.py} extension |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
360 |
\item This file becomes a module! |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
361 |
\item Accessible when in the current directory |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
362 |
\item Use \typ{cd} in IPython to change directory |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
363 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
364 |
\item Naming your module |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
365 |
\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
|
366 |
\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
|
367 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
368 |
\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
|
369 |
\frametitle{Modules: example} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
370 |
\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
|
371 |
# --- arith.py --- |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
372 |
def gcd(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
|
373 |
if a%b == 0: return b |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
374 |
return gcd(b, 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
|
375 |
def lcm(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
|
376 |
return a*b/gcd(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
|
377 |
# ------------------ |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
378 |
>>> import arith |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
379 |
>>> arith.gcd(26, 65) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
380 |
13 |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
381 |
>>> arith.lcm(26, 65) |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
382 |
130 |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
383 |
\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
|
384 |
\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
|
385 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
386 |
\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
|
387 |
\frametitle{Problem 5.1} |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
388 |
|
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
389 |
Put all the functions you have written so far as part of the problems |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
390 |
into one module called \typ{bprim.py} and use this module from 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
|
391 |
|
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
392 |
\inctime{25} |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
393 |
\end{frame} |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
394 |
|
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
395 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
396 |
% TIME: 25 m, running 230m |
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
397 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
398 |
|
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
399 |
\section{Coding Style} |
27
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
400 |
\begin{frame}{Readability and Consistency} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
401 |
\begin{itemize} |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
402 |
\item Readability Counts!\\Code is read more often than its written. |
27
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
403 |
\item Consistency! |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
404 |
\item Know when to be inconsistent. |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
405 |
\end{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
406 |
\end{frame} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
407 |
|
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
408 |
\begin{frame}[fragile] |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
409 |
\frametitle{Code Layout} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
410 |
\begin{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
411 |
\item Indentation |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
412 |
\item Tabs or Spaces?? |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
413 |
\item Maximum Line Length |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
414 |
\item Blank Lines |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
415 |
\item Encodings |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
416 |
\end{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
417 |
\end{frame} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
418 |
|
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
419 |
\begin{frame}{Whitespaces in Expressions} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
420 |
\begin{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
421 |
\item When to use extraneous whitespaces?? |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
422 |
\item When to avoid extra whitespaces?? |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
423 |
\item Use one statement per line |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
424 |
\end{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
425 |
\end{frame} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
426 |
|
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
427 |
\begin{frame}{Comments} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
428 |
\begin{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
429 |
\item No comments better than contradicting comments |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
430 |
\item Block comments |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
431 |
\item Inline comments |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
432 |
\end{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
433 |
\end{frame} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
434 |
|
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
435 |
\begin{frame}{Docstrings} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
436 |
\begin{itemize} |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
437 |
\item When to write docstrings? |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
438 |
\item Ending the docstrings |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
439 |
\item One liner docstrings |
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
440 |
\end{itemize} |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
441 |
More information at PEP8: http://www.python.org/dev/peps/pep-0008/ |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
442 |
\inctime{10} |
27
ecf0f0e885f4
Updated Coding Style slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
26
diff
changeset
|
443 |
\end{frame} |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
444 |
|
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
445 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
446 |
% TIME: 10 m, running 240m |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
447 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
448 |
|
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
449 |
\section{Objects} |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
450 |
\begin{frame}{Objects in general} |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
451 |
\begin{itemize} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
452 |
\item What is an Object? (Types and classes) |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
453 |
\item identity |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
454 |
\item type |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
455 |
\item method |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
456 |
\end{itemize} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
457 |
\end{frame} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
458 |
|
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
459 |
\begin{frame}{Almost everything is an Object!} |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
460 |
\begin{itemize} |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
461 |
\item \typ{list} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
462 |
\item \typ{tuple} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
463 |
\item \typ{string} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
464 |
\item \typ{dictionary} |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
465 |
\item \typ{function} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
466 |
\item Of course, user defined class objects! |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
467 |
\end{itemize} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
468 |
\end {frame} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
469 |
|
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
470 |
\begin{frame}{Using Objects} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
471 |
\begin{itemize} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
472 |
\item Creating Objects: Initialization |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
473 |
\item Object Manipulation: Object methods and ``.'' operator |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
474 |
\end{itemize} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
475 |
\end{frame} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
476 |
|
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
477 |
\begin{frame}[fragile] |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
478 |
\frametitle{IPython Examples} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
479 |
\begin{lstlisting} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
480 |
In [1]: l = [] #Initialising a list object |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
481 |
In [2]: l? |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
482 |
In [3]: l.<tab> |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
483 |
\end{lstlisting} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
484 |
\end{frame} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
485 |
|
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
486 |
\begin{frame}[fragile] |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
487 |
\frametitle{Objects provide consistency} |
47
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
488 |
\small |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
489 |
\begin{lstlisting} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
490 |
for element in (1, 2, 3): |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
491 |
print element |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
492 |
for key in {'one':1, 'two':2}: |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
493 |
print key |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
494 |
for char in "123": |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
495 |
print char |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
496 |
for line in open("myfile.txt"): |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
497 |
print line |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
498 |
for line in urllib2.urlopen('http://site.com'): |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
499 |
print line |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
500 |
\end{lstlisting} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
501 |
\end{frame} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
502 |
|
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
503 |
\begin{frame}{And the winner is \ldots OBJECTS!} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
504 |
All objects providing a similar inteface can be used the same way.\\ |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
505 |
Functions (and others) are first-class objects. Can be passed to and returned from functions. |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
506 |
\inctime{10} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
507 |
\end{frame} |
21de307e6823
Updated session 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
42
diff
changeset
|
508 |
|
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
509 |
\section{Summary} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
510 |
|
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
511 |
\begin{frame}{What have we learnt so far?} |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
512 |
\begin{itemize} |
79
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
513 |
\item Operating on lists and tuples using \kwrd{for} |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
514 |
\item Simple string tokenizing and parsing |
04b620d3f172
Session 3 slides completed.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
74
diff
changeset
|
515 |
\item Writing to and Reading from files using \kwrd{for} |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
516 |
\item Using and writing Python Modules |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
517 |
\item Coding Style |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
518 |
\item Objects in Python |
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
519 |
\end{itemize} |
49
2adb90f9e287
Added what did we learn to all slides and reworked on Session 2 and 4.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
48
diff
changeset
|
520 |
\end{frame} |
74
a476c09dcf24
Session 1 slides completed. Session 3 third iteration.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
53
diff
changeset
|
521 |
|
5
838cedef5e9d
Added 4 tex slides for 4 sessions of Day 1 of the workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
522 |
\end{document} |