day1/tot.tex
changeset 374 0ba81871dae5
parent 373 f04eca8b2f3d
parent 370 b54a496d320c
child 375 30124fd5eb7e
equal deleted inserted replaced
373:f04eca8b2f3d 374:0ba81871dae5
     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, Tricks of the Trade}
       
    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[Tricks of the trade] Thu 09:00--09:30
       
   129 	\item[Session 1] Thu 09:30--10:30
       
   130 	\item[Session 2] Thu 10:45--11:45
       
   131 	\item[Session 3] Thu 11:50--12:30
       
   132 	\item[Session 4] Thu 12:30--1:30
       
   133         \item[Quiz 1] Thu 14:30--14:45
       
   134         \item[Exercises] Thu 14:45--15:30
       
   135         \item[Session 5] Thu 15:45--16:45
       
   136         \item[Quiz 2] Thu 16:50--17:05
       
   137   \end{description}
       
   138 \end{frame}
       
   139 
       
   140 \begin{frame}
       
   141   \frametitle{Workshop Schedule: Day 2}
       
   142   \begin{description}
       
   143 	\item[Session 1] Fri 09:00--10:00
       
   144 	\item[Session 2] Fri 10:05--11:05
       
   145 	\item[Session 3] Fri 11:20--12:20
       
   146 	\item[Session 4] Fri 12:25--13:25
       
   147         \item[Quiz 1]  Fri 14:25--14:40
       
   148         \item[Exercises] Fri 14:40--15:25
       
   149         \item[Session 5] Fri 15:40--16:40
       
   150         \item[Quiz 2]  Fri 16:45--17:00
       
   151   \end{description}
       
   152 \end{frame}
       
   153 
       
   154 \section{Checklist}
       
   155 \begin{frame}
       
   156 \frametitle{Checklist}
       
   157   \begin{enumerate}
       
   158     \item IPython
       
   159     \item Editor
       
   160     \item Data files: 
       
   161       \begin{itemize}
       
   162       \item \typ{sslc1.txt}
       
   163       \item \typ{pendulum.txt}
       
   164       \item \typ{points.txt}
       
   165       \item \typ{pos.txt}
       
   166       \item \typ{holmes.txt}
       
   167       \end{itemize}
       
   168     \item Python scripts: 
       
   169       \begin{itemize}
       
   170       \item \typ{sslc_allreg.py}
       
   171       \item \typ{sslc_science.py}
       
   172       \end{itemize}
       
   173     \item Images
       
   174       \begin{itemize}
       
   175       \item \typ{lena.png}
       
   176       \item \typ{smoothing.gif}
       
   177       \end{itemize}
       
   178   \end{enumerate}
       
   179 \end{frame}
       
   180 
       
   181 \section{Starting up Ipython}
       
   182 \begin{frame}[fragile]
       
   183 \frametitle{Starting up \ldots}
       
   184 \begin{block}{}
       
   185 \begin{lstlisting}
       
   186   $ ipython -pylab  
       
   187 \end{lstlisting} %$
       
   188 \end{block}
       
   189 \begin{lstlisting}     
       
   190   In []: print "Hello, World!"
       
   191   Hello, World!
       
   192 \end{lstlisting}
       
   193 Exiting
       
   194 \begin{lstlisting}
       
   195   In []: ^D(Ctrl-D)
       
   196   Do you really want to exit([y]/n)? y
       
   197 \end{lstlisting}
       
   198 \end{frame}
       
   199 
       
   200 \section{Loops}
       
   201 \begin{frame}[fragile]
       
   202 \frametitle{Loops}
       
   203 Breaking out of loops
       
   204 \begin{lstlisting}     
       
   205   In []: while True:
       
   206     ...:     print "Hello, World!"
       
   207     ...:     
       
   208   Hello, World!
       
   209   Hello, World!^C(Ctrl-C)
       
   210   ------------------------------------
       
   211   KeyboardInterrupt                   
       
   212 \end{lstlisting}
       
   213 \end{frame}
       
   214 
       
   215 \section{Indentation}
       
   216 \begin{frame}[fragile]
       
   217   \frametitle{Indentation}
       
   218   \begin{lstlisting}
       
   219   In []: while True:
       
   220     ...:     print "Hello, World!"
       
   221     ...:     
       
   222   \end{lstlisting}
       
   223 \emphbar{\alert{Indentation: Notice the 4 spaces before\\} \typ{print "Hello, World!"}\\
       
   224   Hit the ``ENTER'' key twice to return to the previous indentation level}
       
   225 \end{frame}
       
   226 
       
   227 \section{Tab Completion}
       
   228 \begin{frame}[fragile]
       
   229   \frametitle{Tab Completion}
       
   230   Type \typ{pri} and hit the Tab key
       
   231   \begin{lstlisting}
       
   232     In []: pri <Tab>
       
   233     In []: print
       
   234   \end{lstlisting}
       
   235   Type \typ{whi} and hit the Tab key
       
   236   \begin{lstlisting}
       
   237     In []: whi <Tab>
       
   238     In []: while
       
   239   \end{lstlisting}
       
   240 \end{frame}
       
   241 
       
   242 \section{Tab Suggestions}
       
   243 \begin{frame}[fragile]
       
   244   \frametitle{Tab Suggestions}
       
   245   \begin{lstlisting}
       
   246 In []: a = 'Hello world'
       
   247 
       
   248 In []: a.<Tab>
       
   249   \end{lstlisting}
       
   250   \ldots
       
   251 \end{frame}
       
   252 
       
   253 \section{Command history}
       
   254 \begin{frame}[fragile]
       
   255   \frametitle{Command history}
       
   256   \typ{In []:} \alert{$\uparrow$}\\
       
   257   \typ{In []: a = 'Hello world'}\\
       
   258   \emphbar{The previously entered commands can be browsed using the \alert{$\uparrow$} key.}
       
   259 \end{frame}
       
   260 
       
   261 \section{Saving Commands}
       
   262 \begin{frame}[fragile]
       
   263 \frametitle{History and Saving of Commands}
       
   264 \begin{itemize}
       
   265 \item \typ{\%hist} gives history of commands in a session
       
   266 \item \typ{\%save} can be used to save the commands
       
   267 \end{itemize}
       
   268 \begin{block}{Careful about errors!}
       
   269   \kwrd{\%hist} will contain the errors as well,\\
       
   270   so be careful while selecting line numbers.
       
   271 \end{block}
       
   272 \end{frame}
       
   273 
       
   274 \section{Editors}
       
   275 \begin{frame}[fragile]
       
   276   \frametitle{Editors}
       
   277   The following are some good editors:
       
   278   \begin{itemize}
       
   279   \item emacs
       
   280   \item vim
       
   281   \item \alert{scite} - we recommend it
       
   282   \end{itemize}
       
   283 \end{frame}
       
   284 
       
   285 \section{Scite - How to}
       
   286 \begin{frame}[fragile]
       
   287   \frametitle{Scite - How to \ldots}
       
   288   \begin{itemize}
       
   289   \item Opening scite
       
   290     \begin{itemize}
       
   291     \item GNU/Linux: \alert{Applications} $\rightarrow$ \alert{Programming} $\rightarrow$ \alert{SciTE Text Editor}
       
   292     \item Windows: Double click on the \alert{SciTE} Desktop icon
       
   293     \end{itemize}
       
   294   \item Type the contents
       
   295   \item Saving the file with a filename \alert{File $\rightarrow$ Save as}
       
   296   \item Saving the file  \alert{File $\rightarrow$ Save}
       
   297   \item Exiting the editor  \alert{File $\rightarrow$ Exit}
       
   298   \item To open an existing file: \alert{File $\rightarrow$ Open}
       
   299   \end{itemize}
       
   300 \end{frame}
       
   301 
       
   302 \section{Summary}
       
   303 \begin{frame}[fragile]
       
   304   \frametitle{What did we learn?}
       
   305   \begin{itemize}
       
   306     \item Starting up IPython
       
   307     \item Loops - Indentation and breaking out of loops
       
   308     \item \kwrd{\%hist} - History of commands
       
   309     \item \kwrd{\%save} - Saving commands 
       
   310     \item Using SciTE
       
   311   \end{itemize}
       
   312 \end{frame}
       
   313 
       
   314 \end{document}