advanced-features-functions/slides.org
changeset 522 d33698326409
parent 521 88a01948450d
child 523 54bdda4aefa5
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:    Advanced features of functions
       
    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 
       
    32 * Outline
       
    33   - Assigning default values to arguments
       
    34   - Calling functions using Keyword arguments
       
    35   - functions in standard library 
       
    36 * Question 1
       
    37   Redefine the function ~welcome~, by interchanging it's
       
    38   arguments. Place the ~name~ argument with it's default value of
       
    39   "World" before the ~greet~ argument.
       
    40 * Solution 1
       
    41   #+begin_src python
       
    42     def welcome(name="World", greet):
       
    43         print greet, name
       
    44   #+end_src
       
    45   We get an error that reads ~SyntaxError: non-default argument
       
    46   follows default argument~. When defining a function all the
       
    47   argument with default values should come at the end.
       
    48 
       
    49 * Question 2
       
    50   See the definition of linspace using ~?~ and observe how all the
       
    51   arguments with default values are towards the end.
       
    52 * Solution 2
       
    53   #+begin_src python
       
    54     linspace?
       
    55   #+end_src
       
    56 * Question 3
       
    57   Redefine the function ~welcome~ with a default value of
       
    58   "Hello" to the ~greet~ argument. Then, call the function without any
       
    59   arguments. 
       
    60 * Solution 3
       
    61   #+begin_src python
       
    62     def welcome(greet="Hello", name="World"):
       
    63         print greet, name
       
    64      
       
    65     welcome()
       
    66   #+end_src
       
    67 * Summary
       
    68   You should now be able to --
       
    69   + define functions with default arguments
       
    70   + call functions using keyword arguments
       
    71 * Thank you!
       
    72 #+begin_latex
       
    73   \begin{block}{}
       
    74   \begin{center}
       
    75   This spoken tutorial has been produced by the
       
    76   \textcolor{blue}{FOSSEE} team, which is funded by the 
       
    77   \end{center}
       
    78   \begin{center}
       
    79     \textcolor{blue}{National Mission on Education through \\
       
    80       Information \& Communication Technology \\ 
       
    81       MHRD, Govt. of India}.
       
    82   \end{center}  
       
    83   \end{block}
       
    84 #+end_latex
       
    85 
       
    86