advanced-features-functions/slides.tex
author Nishanth <nishanth@fossee.in>
Mon, 11 Oct 2010 23:36:15 +0530
changeset 303 56dc2183f1de
parent 272 08638b1e211e
child 367 2ca9b21ed8f9
permissions -rw-r--r--
Merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     1
% Created 2010-10-11 Mon 00:34
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     2
\documentclass[presentation]{beamer}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
\usepackage[latin1]{inputenc}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
\usepackage[T1]{fontenc}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     5
\usepackage{fixltx2e}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     6
\usepackage{graphicx}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     7
\usepackage{longtable}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     8
\usepackage{float}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     9
\usepackage{wrapfig}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    10
\usepackage{soul}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    11
\usepackage{textcomp}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    12
\usepackage{marvosym}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    13
\usepackage{wasysym}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    14
\usepackage{latexsym}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    15
\usepackage{amssymb}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    16
\usepackage{hyperref}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    17
\tolerance=1000
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    18
\usepackage[english]{babel} \usepackage{ae,aecompl}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    19
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    20
\usepackage{listings}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    21
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    22
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    23
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    24
\providecommand{\alert}[1]{\textbf{#1}}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    26
\title{Advanced features of functions}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    27
\author{FOSSEE}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
\date{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    30
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    31
\begin{document}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    33
\maketitle
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    34
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    35
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    36
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    37
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    38
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    39
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    40
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    41
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    42
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    43
\begin{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    44
\frametitle{Outline}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    45
\label{sec-1}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    46
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    47
\begin{itemize}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    48
\item Assigning default values to arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    49
\item Calling functions using Keyword arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    50
\item functions in standard library
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    51
\end{itemize}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    52
\end{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    53
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    54
\frametitle{Question 1}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    55
\label{sec-2}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    56
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    57
  Redefine the function \texttt{welcome}, by interchanging it's
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    58
  arguments. Place the \texttt{name} argument with it's default value of
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    59
  ``World'' before the \texttt{greet} argument.
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    60
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    61
\begin{frame}[fragile]
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    62
\frametitle{Solution 1}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    63
\label{sec-3}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    64
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    65
\lstset{language=Python}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    66
\begin{lstlisting}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    67
def welcome(name="World", greet):
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    68
    print greet, name
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    69
\end{lstlisting}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    70
  We get an error that reads \texttt{SyntaxError: non-default argument   follows default argument}. When defining a function all the
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    71
  argument with default values should come at the end.
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    72
\end{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    73
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    74
\frametitle{Question 2}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    75
\label{sec-4}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    76
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    77
  See the definition of linspace using \texttt{?} and observe how all the
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    78
  arguments with default values are towards the end.
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    79
\end{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    80
\begin{frame}[fragile]
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    81
\frametitle{Solution 2}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    82
\label{sec-5}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    83
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    84
\lstset{language=Python}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    85
\begin{lstlisting}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    86
linspace?
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    87
\end{lstlisting}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    88
\end{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    89
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    90
\frametitle{Question 3}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    91
\label{sec-6}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    92
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    93
  Redefine the function \texttt{welcome} with a default value of
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    94
  ``Hello'' to the \texttt{greet} argument. Then, call the function without any
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    95
  arguments. 
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    96
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    97
\begin{frame}[fragile]
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    98
\frametitle{Solution 3}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    99
\label{sec-7}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   100
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   101
\lstset{language=Python}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   102
\begin{lstlisting}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   103
def welcome(greet="Hello", name="World"):
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   104
    print greet, name
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   105
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   106
welcome()
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   107
\end{lstlisting}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
\begin{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   110
\frametitle{Summary}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   111
\label{sec-8}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   112
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   113
  You should now be able to --
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   114
\begin{itemize}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   115
\item define functions with default arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   116
\item call functions using keyword arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   117
\end{itemize}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   118
\end{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   119
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   120
\frametitle{Thank you!}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   121
\label{sec-9}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   122
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   123
  \begin{block}{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
  This spoken tutorial has been produced by the
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   126
  \textcolor{blue}{FOSSEE} team, which is funded by the 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   127
  \end{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   128
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   129
    \textcolor{blue}{National Mission on Education through \\
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   130
      Information \& Communication Technology \\ 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   131
      MHRD, Govt. of India}.
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   132
  \end{center}  
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   133
  \end{block}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   134
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   135
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   136
\end{document}