manipulating_lists/slides.tex
changeset 522 d33698326409
equal deleted inserted replaced
521:88a01948450d 522:d33698326409
       
     1 % Created 2010-11-09 Tue 16:07
       
     2 \documentclass[presentation]{beamer}
       
     3 \usepackage[latin1]{inputenc}
       
     4 \usepackage[T1]{fontenc}
       
     5 \usepackage{fixltx2e}
       
     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}}
       
    25 
       
    26 \title{Manipulating Lists}
       
    27 \author{FOSSEE}
       
    28 \date{}
       
    29 
       
    30 \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
       
    31 \begin{document}
       
    32 
       
    33 \maketitle
       
    34 
       
    35 
       
    36 
       
    37 
       
    38 
       
    39 
       
    40 
       
    41 
       
    42 
       
    43 \begin{frame}
       
    44 \frametitle{Outline}
       
    45 \label{sec-1}
       
    46 
       
    47   In this session we shall be looking at 
       
    48 \begin{itemize}
       
    49 \item Concatenating lists
       
    50 \item Obtaining parts of lists
       
    51 \item Sorting lists
       
    52 \item Reversing lists
       
    53 \end{itemize}
       
    54 \end{frame}
       
    55 \begin{frame}
       
    56 \frametitle{Question 1}
       
    57 \label{sec-2}
       
    58 
       
    59   Obtain the primes less than 10, from the list \texttt{primes}. 
       
    60 \end{frame}
       
    61 \begin{frame}[fragile]
       
    62 \frametitle{Solution 1}
       
    63 \label{sec-3}
       
    64 
       
    65 \lstset{language=Python}
       
    66 \begin{lstlisting}
       
    67 primes[0:4]
       
    68 \end{lstlisting}
       
    69 \end{frame}
       
    70 \begin{frame}[fragile]
       
    71 \frametitle{Slicing}
       
    72 \label{sec-4}
       
    73 
       
    74 \lstset{language=Python}
       
    75 \begin{lstlisting}
       
    76 p[start:stop]
       
    77 \end{lstlisting}
       
    78 \begin{itemize}
       
    79 \item Returns all elements of \texttt{p} between \texttt{start} and \texttt{stop}
       
    80 \item The element with index equal to \texttt{stop} is \textbf{not} included.
       
    81 \end{itemize}
       
    82 \end{frame}
       
    83 \begin{frame}
       
    84 \frametitle{Question 2}
       
    85 \label{sec-5}
       
    86 
       
    87   Obtain all the multiples of three from the list \texttt{num}.
       
    88 \end{frame}
       
    89 \begin{frame}[fragile]
       
    90 \frametitle{Solution 2}
       
    91 \label{sec-6}
       
    92 
       
    93 \lstset{language=Python}
       
    94 \begin{lstlisting}
       
    95 num[::3]
       
    96 \end{lstlisting}
       
    97 \end{frame}
       
    98 \begin{frame}[fragile]
       
    99 \frametitle{Question 3}
       
   100 \label{sec-7}
       
   101 
       
   102   Given a list of marks of students in an examination, obtain a list
       
   103   with marks in descending order.
       
   104 \lstset{language=Python}
       
   105 \begin{lstlisting}
       
   106 marks = [99, 67, 47, 100, 50, 75, 62]
       
   107 \end{lstlisting}
       
   108 \end{frame}
       
   109 \begin{frame}[fragile]
       
   110 \frametitle{Solution 3}
       
   111 \label{sec-8}
       
   112 
       
   113 \lstset{language=Python}
       
   114 \begin{lstlisting}
       
   115 sorted(marks)[::-1]
       
   116 \end{lstlisting}
       
   117 OR
       
   118 \lstset{language=Python}
       
   119 \begin{lstlisting}
       
   120 sorted(marks, reverse=True)
       
   121 \end{lstlisting}
       
   122 \end{frame}
       
   123 \begin{frame}
       
   124 \frametitle{Summary}
       
   125 \label{sec-9}
       
   126 
       
   127   In this tutorial session we learnt
       
   128 \begin{itemize}
       
   129 \item Obtaining parts of lists using slicing and striding
       
   130 \item List concatenation
       
   131 \item Sorting lists
       
   132 \item Reversing lists
       
   133 \end{itemize}
       
   134 \end{frame}
       
   135 \begin{frame}
       
   136 \frametitle{Thank you!}
       
   137 \label{sec-10}
       
   138 
       
   139   \begin{block}{}
       
   140   \begin{center}
       
   141   This spoken tutorial has been produced by the
       
   142   \textcolor{blue}{FOSSEE} team, which is funded by the 
       
   143   \end{center}
       
   144   \begin{center}
       
   145     \textcolor{blue}{National Mission on Education through \\
       
   146       Information \& Communication Technology \\ 
       
   147       MHRD, Govt. of India}.
       
   148   \end{center}  
       
   149   \end{block}
       
   150 \end{frame}
       
   151 
       
   152 \end{document}