|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
2 %Tutorial slides on Python. |
|
3 % |
|
4 % Author: FOSSEE |
|
5 % Copyright (c) 2009, FOSSEE, IIT Bombay |
|
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
7 |
|
8 \documentclass[14pt,compress]{beamer} |
|
9 %\documentclass[draft]{beamer} |
|
10 %\documentclass[compress,handout]{beamer} |
|
11 %\usepackage{pgfpages} |
|
12 %\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
|
13 |
|
14 % Modified from: generic-ornate-15min-45min.de.tex |
|
15 \mode<presentation> |
|
16 { |
|
17 \usetheme{Warsaw} |
|
18 \useoutertheme{infolines} |
|
19 \setbeamercovered{transparent} |
|
20 } |
|
21 |
|
22 \usepackage[english]{babel} |
|
23 \usepackage[latin1]{inputenc} |
|
24 %\usepackage{times} |
|
25 \usepackage[T1]{fontenc} |
|
26 |
|
27 % Taken from Fernando's slides. |
|
28 \usepackage{ae,aecompl} |
|
29 \usepackage{mathpazo,courier,euler} |
|
30 \usepackage[scaled=.95]{helvet} |
|
31 |
|
32 \definecolor{darkgreen}{rgb}{0,0.5,0} |
|
33 |
|
34 \usepackage{listings} |
|
35 \lstset{language=Python, |
|
36 basicstyle=\ttfamily\bfseries, |
|
37 commentstyle=\color{red}\itshape, |
|
38 stringstyle=\color{darkgreen}, |
|
39 showstringspaces=false, |
|
40 keywordstyle=\color{blue}\bfseries} |
|
41 |
|
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
43 % Macros |
|
44 \setbeamercolor{emphbar}{bg=blue!20, fg=black} |
|
45 \newcommand{\emphbar}[1] |
|
46 {\begin{beamercolorbox}[rounded=true]{emphbar} |
|
47 {#1} |
|
48 \end{beamercolorbox} |
|
49 } |
|
50 \newcounter{time} |
|
51 \setcounter{time}{0} |
|
52 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
|
53 |
|
54 \newcommand{\typ}[1]{\lstinline{#1}} |
|
55 |
|
56 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
|
57 |
|
58 %%% This is from Fernando's setup. |
|
59 % \usepackage{color} |
|
60 % \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
|
61 % % Use and configure listings package for nicely formatted code |
|
62 % \usepackage{listings} |
|
63 % \lstset{ |
|
64 % language=Python, |
|
65 % basicstyle=\small\ttfamily, |
|
66 % commentstyle=\ttfamily\color{blue}, |
|
67 % stringstyle=\ttfamily\color{orange}, |
|
68 % showstringspaces=false, |
|
69 % breaklines=true, |
|
70 % postbreak = \space\dots |
|
71 % } |
|
72 |
|
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
74 % Title page |
|
75 \title[Tricks of the trade]{Python for Science and Engg: Tricks of the trade} |
|
76 |
|
77 \author[FOSSEE] {FOSSEE} |
|
78 |
|
79 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
|
80 \date[] {28 January, 2010\\Day 1, Introduction} |
|
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
82 |
|
83 %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
|
84 %\logo{\pgfuseimage{iitmlogo}} |
|
85 |
|
86 |
|
87 %% Delete this, if you do not want the table of contents to pop up at |
|
88 %% the beginning of each subsection: |
|
89 \AtBeginSubsection[] |
|
90 { |
|
91 \begin{frame}<beamer> |
|
92 \frametitle{Outline} |
|
93 \tableofcontents[currentsection,currentsubsection] |
|
94 \end{frame} |
|
95 } |
|
96 |
|
97 \AtBeginSection[] |
|
98 { |
|
99 \begin{frame}<beamer> |
|
100 \frametitle{Outline} |
|
101 \tableofcontents[currentsection,currentsubsection] |
|
102 \end{frame} |
|
103 } |
|
104 |
|
105 % If you wish to uncover everything in a step-wise fashion, uncomment |
|
106 % the following command: |
|
107 %\beamerdefaultoverlayspecification{<+->} |
|
108 |
|
109 %%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
|
110 |
|
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
112 % DOCUMENT STARTS |
|
113 \begin{document} |
|
114 |
|
115 \begin{frame} |
|
116 \maketitle |
|
117 \end{frame} |
|
118 |
|
119 %% \begin{frame} |
|
120 %% \frametitle{Outline} |
|
121 %% \tableofcontents |
|
122 %% % You might wish to add the option [pausesections] |
|
123 %% \end{frame} |
|
124 |
|
125 \begin{frame} |
|
126 \frametitle{Workshop Schedule: Day 1} |
|
127 \begin{description} |
|
128 \item[Session 1] Mon 09:00--10:00 |
|
129 \item[Session 2] Mon 10:05--11:05 |
|
130 \item[Session 3] Mon 11:20--12:20 |
|
131 \item[Session 4] Mon 12:25--13:25 |
|
132 \item[Quiz 1] Mon 14:25--14:40 |
|
133 \item[Exercises] Mon 14:40--15:25 |
|
134 \item[Session 5] Mon 15:40--16:40 |
|
135 \item[Quiz 2] Mon 16:45--17:00 |
|
136 \end{description} |
|
137 \end{frame} |
|
138 |
|
139 \begin{frame} |
|
140 \frametitle{Workshop Schedule: Day 2} |
|
141 \begin{description} |
|
142 \item[Session 1] Tue 09:00--10:00 |
|
143 \item[Session 2] Tue 10:05--11:05 |
|
144 \item[Session 3] Tue 11:20--12:20 |
|
145 \item[Session 4] Tue 12:25--13:25 |
|
146 \item[Quiz 1] Tue 14:25--14:40 |
|
147 \item[Exercises] Tue 14:40--15:25 |
|
148 \item[Session 5] Tue 15:40--16:40 |
|
149 \item[Quiz 2] Tue 16:45--17:00 |
|
150 \end{description} |
|
151 \end{frame} |
|
152 |
|
153 \section{Checklist} |
|
154 \begin{frame} |
|
155 \frametitle{Checklist} |
|
156 \begin{enumerate} |
|
157 \item IPython |
|
158 \item Editor: We recommend \alert{scite}. |
|
159 \item Data files: |
|
160 \begin{itemize} |
|
161 \item \typ{sslc1.txt} |
|
162 \item \typ{pendulum.txt} |
|
163 \item \typ{points.txt} |
|
164 \item \typ{pos.txt} |
|
165 \item \typ{holmes.txt} |
|
166 \end{itemize} |
|
167 \item Python scripts: |
|
168 \begin{itemize} |
|
169 \item \typ{sslc_allreg.py} |
|
170 \item \typ{sslc_science.py} |
|
171 \end{itemize} |
|
172 \item Images |
|
173 \begin{itemize} |
|
174 \item \typ{lena.png} |
|
175 \item \typ{smoothing.gif} |
|
176 \end{itemize} |
|
177 \end{enumerate} |
|
178 \end{frame} |
|
179 |
|
180 \section{Starting up Ipython} |
|
181 \begin{frame}[fragile] |
|
182 \frametitle{Starting up \ldots} |
|
183 \begin{block}{} |
|
184 \begin{lstlisting} |
|
185 $ ipython -pylab |
|
186 \end{lstlisting} %$ |
|
187 \end{block} |
|
188 \begin{lstlisting} |
|
189 In []: print "Hello, World!" |
|
190 Hello, World! |
|
191 \end{lstlisting} |
|
192 Exiting |
|
193 \begin{lstlisting} |
|
194 In []: ^D(Ctrl-D) |
|
195 Do you really want to exit([y]/n)? y |
|
196 \end{lstlisting} |
|
197 \end{frame} |
|
198 |
|
199 \section{Loops - Indentation and Breaking out of loops} |
|
200 \begin{frame}[fragile] |
|
201 \frametitle{Loops} |
|
202 Breaking out of loops |
|
203 \begin{lstlisting} |
|
204 In []: while True: |
|
205 ...: print "Hello, World!" |
|
206 ...: |
|
207 Hello, World! |
|
208 Hello, World!^C(Ctrl-C) |
|
209 ------------------------------------ |
|
210 KeyboardInterrupt |
|
211 |
|
212 \end{lstlisting} |
|
213 \emphbar{\alert{Indentation: Notice the 4 spaces after\\} \typ{while True:}} |
|
214 \end{frame} |
|
215 |
|
216 \section{Saving Commands} |
|
217 \begin{frame}[fragile] |
|
218 \frametitle{History and Saving of Commands} |
|
219 \begin{itemize} |
|
220 \item \typ{\%hist} gives complete history of commands in a session |
|
221 \item \typ{\%save} can be used to save the commands |
|
222 \end{itemize} |
|
223 \begin{block}{Careful about errors!} |
|
224 \kwrd{\%hist} will contain the errors as well,\\ |
|
225 so be careful while selecting line numbers. |
|
226 \end{block} |
|
227 \end{frame} |
|
228 |
|
229 \section{Editors} |
|
230 \begin{frame}[fragile] |
|
231 \frametitle{Editors} |
|
232 The following are some good editors: |
|
233 \begin{itemize} |
|
234 \item emacs |
|
235 \item vim |
|
236 \item scite - we recommend scite |
|
237 \end{itemize} |
|
238 \end{frame} |
|
239 |
|
240 \section{Scite - How to} |
|
241 \begin{frame}[fragile] |
|
242 \frametitle{Scite - How to \ldots} |
|
243 \begin{itemize} |
|
244 \item Opening a file |
|
245 \item Saving a file |
|
246 \item Exiting the editor |
|
247 \end{itemize} |
|
248 \end{frame} |
|
249 |
|
250 \section{Summary} |
|
251 \begin{frame}[fragile] |
|
252 \frametitle{What did we learn?} |
|
253 \begin{itemize} |
|
254 \item Starting up IPython |
|
255 \item Loops - Indentation and breaking out of loops |
|
256 \item \kwrd{\%hist} |
|
257 \item Saving commands to a script |
|
258 \end{itemize} |
|
259 \end{frame} |
|
260 |
|
261 \end{document} |