parsing_data/slides.tex
changeset 280 40b6a90f41b7
parent 238 c507e9c413c6
equal deleted inserted replaced
279:5c9dc3419df5 280:40b6a90f41b7
     1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1 % Created 2010-10-10 Sun 18:28
     2 %Tutorial slides on Python.
     2 \documentclass[presentation]{beamer}
     3 %
     3 \usepackage[latin1]{inputenc}
     4 % Author: FOSSEE 
     4 \usepackage[T1]{fontenc}
     5 % Copyright (c) 2009, FOSSEE, IIT Bombay
     5 \usepackage{fixltx2e}
     6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     6 \usepackage{graphicx}
       
     7 \usepackage{longtable}
       
     8 \usepackage{float}
       
     9 \usepackage{wrapfig}
       
    10 \usepackage{soul}
       
    11 \usepackage{textcomp}
       
    12 \usepackage{marvosym}
       
    13 \usepackage{wasysym}
       
    14 \usepackage{latexsym}
       
    15 \usepackage{amssymb}
       
    16 \usepackage{hyperref}
       
    17 \tolerance=1000
       
    18 \usepackage[english]{babel} \usepackage{ae,aecompl}
       
    19 \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
       
    20 \usepackage{listings}
       
    21 \lstset{language=Python, basicstyle=\ttfamily\bfseries,
       
    22 commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
       
    23 showstringspaces=false, keywordstyle=\color{blue}\bfseries}
       
    24 \providecommand{\alert}[1]{\textbf{#1}}
     7 
    25 
     8 \documentclass[14pt,compress]{beamer}
    26 \title{Parsing Data}
     9 %\documentclass[draft]{beamer}
    27 \author{FOSSEE}
    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 \usepackage{ae,aecompl}
       
    28 \usepackage{mathpazo,courier,euler}
       
    29 \usepackage[scaled=.95]{helvet}
       
    30 
       
    31 \definecolor{darkgreen}{rgb}{0,0.5,0}
       
    32 
       
    33 \usepackage{listings}
       
    34 \lstset{language=Python,
       
    35     basicstyle=\ttfamily\bfseries,
       
    36     commentstyle=\color{red}\itshape,
       
    37   stringstyle=\color{darkgreen},
       
    38   showstringspaces=false,
       
    39   keywordstyle=\color{blue}\bfseries}
       
    40 
       
    41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    42 % Macros
       
    43 \setbeamercolor{emphbar}{bg=blue!20, fg=black}
       
    44 \newcommand{\emphbar}[1]
       
    45 {\begin{beamercolorbox}[rounded=true]{emphbar} 
       
    46       {#1}
       
    47  \end{beamercolorbox}
       
    48 }
       
    49 \newcounter{time}
       
    50 \setcounter{time}{0}
       
    51 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
       
    52 
       
    53 \newcommand{\typ}[1]{\lstinline{#1}}
       
    54 
       
    55 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
       
    56 
       
    57 % Title page
       
    58 \title{Your Title Here}
       
    59 
       
    60 \author[FOSSEE] {FOSSEE}
       
    61 
       
    62 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
       
    63 \date{}
    28 \date{}
    64 
    29 
    65 % DOCUMENT STARTS
    30 \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
    66 \begin{document}
    31 \begin{document}
    67 
    32 
    68 \begin{frame}
    33 \maketitle
    69   \maketitle
       
    70 \end{frame}
       
    71 
    34 
    72 \begin{frame}[fragile]
       
    73   \frametitle{Outline}
       
    74   \begin{itemize}
       
    75     \item 
       
    76   \end{itemize}
       
    77 \end{frame}
       
    78 
    35 
    79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    80 %%              All other slides here.                  %%
       
    81 %% The same slides will be used in a classroom setting. %% 
       
    82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    83 
    36 
    84 \begin{frame}[fragile]
    37 
    85   \frametitle{Summary}
    38 
    86   \begin{itemize}
    39 
    87     \item 
    40 
    88   \end{itemize}
    41 
    89 \end{frame}
       
    90 
    42 
    91 \begin{frame}
    43 \begin{frame}
    92   \frametitle{Thank you!}  
    44 \frametitle{Outline}
       
    45 \label{sec-1}
       
    46 
       
    47 \begin{itemize}
       
    48 \item What is meant by parsing data?
       
    49 \item String operations required for parsing
       
    50 \item Converting between data-types.
       
    51 \end{itemize}
       
    52 \end{frame}
       
    53 \begin{frame}
       
    54 \frametitle{Question 1}
       
    55 \label{sec-2}
       
    56 
       
    57   Split the variable line using a space as argument. Is it same as
       
    58   splitting without an argument ?
       
    59 \end{frame}
       
    60 \begin{frame}
       
    61 \frametitle{Solution 1}
       
    62 \label{sec-3}
       
    63 
       
    64   We see that when we split on space, multiple whitespaces are not
       
    65   clubbed as one and there is an empty string everytime there are two
       
    66   consecutive spaces.
       
    67 \end{frame}
       
    68 \begin{frame}
       
    69 \frametitle{Question 2}
       
    70 \label{sec-4}
       
    71 
       
    72   What happens to the white space inside the sentence when it is
       
    73   stripped? 
       
    74 \end{frame}
       
    75 \begin{frame}[fragile]
       
    76 \frametitle{Solution 2}
       
    77 \label{sec-5}
       
    78 
       
    79 \lstset{language=Python}
       
    80 \begin{lstlisting}
       
    81 In []: a_str = "     white      space     "
       
    82 In []: a_str.strip()
       
    83 \end{lstlisting}
       
    84 \end{frame}
       
    85 \begin{frame}
       
    86 \frametitle{Question 3}
       
    87 \label{sec-6}
       
    88 
       
    89   What happens if you do \texttt{int("1.25")}
       
    90 \end{frame}
       
    91 \begin{frame}[fragile]
       
    92 \frametitle{Solution 3}
       
    93 \label{sec-7}
       
    94 
       
    95   It raises an error since converting a float string into integer
       
    96   directly is not possible. It involves an intermediate step of
       
    97   converting to float.
       
    98 \lstset{language=Python}
       
    99 \begin{lstlisting}
       
   100 In []: dcml_str = "1.25"
       
   101 In []: flt = float(dcml_str)
       
   102 In []: flt
       
   103 In []: number = int(flt)
       
   104 In []: number
       
   105 \end{lstlisting}
       
   106 \end{frame}
       
   107 \begin{frame}
       
   108 \frametitle{Summary}
       
   109 \label{sec-8}
       
   110 
       
   111 \begin{itemize}
       
   112 \item How to tokenize a string using various delimiters
       
   113 \item How to get rid of extra white space around
       
   114 \item How to convert from one type to another
       
   115 \item How to parse input data and perform computations on it
       
   116 \end{itemize}
       
   117 \end{frame}
       
   118 \begin{frame}
       
   119 \frametitle{Thank you!}
       
   120 \label{sec-9}
       
   121 
    93   \begin{block}{}
   122   \begin{block}{}
    94   \begin{center}
   123   \begin{center}
    95   This spoken tutorial has been produced by the
   124   This spoken tutorial has been produced by the
    96   \textcolor{blue}{FOSSEE} team, which is funded by the 
   125   \textcolor{blue}{FOSSEE} team, which is funded by the 
    97   \end{center}
   126   \end{center}