manipulating_lists/slides.org
changeset 522 d33698326409
equal deleted inserted replaced
521:88a01948450d 522:d33698326409
       
     1 #+LaTeX_CLASS: beamer
       
     2 #+LaTeX_CLASS_OPTIONS: [presentation]
       
     3 #+BEAMER_FRAME_LEVEL: 1
       
     4 
       
     5 #+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
       
     6 #+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
       
     7 #+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
       
     8 
       
     9 #+LaTeX_CLASS: beamer
       
    10 #+LaTeX_CLASS_OPTIONS: [presentation]
       
    11 
       
    12 #+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
       
    13 #+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
       
    14 
       
    15 #+LaTeX_HEADER: \usepackage{listings}
       
    16 
       
    17 #+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
       
    18 #+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
       
    19 #+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
       
    20 
       
    21 #+TITLE:    Manipulating Lists
       
    22 #+AUTHOR:    FOSSEE
       
    23 #+EMAIL:     
       
    24 #+DATE:    
       
    25 
       
    26 #+DESCRIPTION: 
       
    27 #+KEYWORDS: 
       
    28 #+LANGUAGE:  en
       
    29 #+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
       
    30 #+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
       
    31 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
       
    32 
       
    33 * Outline
       
    34   In this session we shall be looking at 
       
    35   - Concatenating lists
       
    36   - Obtaining parts of lists
       
    37   - Sorting lists
       
    38   - Reversing lists
       
    39 * Question 1
       
    40   Obtain the primes less than 10, from the list ~primes~. 
       
    41 * Solution 1
       
    42   #+begin_src python
       
    43     primes[0:4]
       
    44   #+end_src python
       
    45 * Slicing
       
    46   #+begin_src python
       
    47     p[start:stop]
       
    48   #+end_src python
       
    49   - Returns all elements of ~p~ between ~start~ and ~stop~
       
    50   - The element with index equal to ~stop~ is *not* included. 
       
    51 * Question 2
       
    52   Obtain all the multiples of three from the list ~num~.
       
    53 * Solution 2
       
    54   #+begin_src python
       
    55     num[::3]  
       
    56   #+end_src python
       
    57 * Question 3
       
    58   Given a list of marks of students in an examination, obtain a list
       
    59   with marks in descending order.
       
    60   #+begin_src python
       
    61     marks = [99, 67, 47, 100, 50, 75, 62]
       
    62   #+end_src python
       
    63 * Solution 3
       
    64   #+begin_src python
       
    65     sorted(marks)[::-1]
       
    66   #+end_src python
       
    67 OR
       
    68   #+begin_src python
       
    69     sorted(marks, reverse=True)
       
    70   #+end_src python
       
    71 
       
    72 * Summary
       
    73   In this tutorial session we learnt
       
    74     + Obtaining parts of lists using slicing and striding
       
    75     + List concatenation
       
    76     + Sorting lists 
       
    77     + Reversing lists
       
    78 
       
    79 * Thank you!
       
    80 #+begin_latex
       
    81   \begin{block}{}
       
    82   \begin{center}
       
    83   This spoken tutorial has been produced by the
       
    84   \textcolor{blue}{FOSSEE} team, which is funded by the 
       
    85   \end{center}
       
    86   \begin{center}
       
    87     \textcolor{blue}{National Mission on Education through \\
       
    88       Information \& Communication Technology \\ 
       
    89       MHRD, Govt. of India}.
       
    90   \end{center}  
       
    91   \end{block}
       
    92 #+end_latex
       
    93 
       
    94