advanced-features-functions/slides.tex
author amit
Thu, 28 Oct 2010 15:37:18 +0530
changeset 375 c62b166b3f00
parent 367 2ca9b21ed8f9
permissions -rw-r--r--
changes to progress.org
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
     1
% Created 2010-10-28 Thu 11:37
272
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}
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
    11
\usepackage{t1enc}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    12
\usepackage{textcomp}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    13
\usepackage{marvosym}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    14
\usepackage{wasysym}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    15
\usepackage{latexsym}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    16
\usepackage{amssymb}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    17
\usepackage{hyperref}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    18
\tolerance=1000
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    19
\usepackage[english]{babel} \usepackage{ae,aecompl}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    20
\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
    21
\usepackage{listings}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    22
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    23
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    24
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    25
\providecommand{\alert}[1]{\textbf{#1}}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    27
\title{Advanced features of functions}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    28
\author{FOSSEE}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
\date{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    31
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
\begin{document}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    34
\maketitle
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
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    43
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
\begin{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    45
\frametitle{Outline}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    46
\label{sec-1}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    47
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    48
\begin{itemize}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    49
\item Assigning default values to arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    50
\item Calling functions using Keyword arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    51
\item functions in standard library
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    52
\end{itemize}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    53
\end{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    54
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    55
\frametitle{Question 1}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    56
\label{sec-2}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    57
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    58
  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
    59
  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
    60
  ``World'' before the \texttt{greet} argument.
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    61
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    62
\begin{frame}[fragile]
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    63
\frametitle{Solution 1}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    64
\label{sec-3}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    65
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
    66
\begin{verbatim}
272
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
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
    69
\end{verbatim}
272
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
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
    84
\begin{verbatim}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    85
linspace?
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
    86
\end{verbatim}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    87
\end{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    88
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    89
\frametitle{Question 3}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    90
\label{sec-6}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    91
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    92
  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
    93
  ``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
    94
  arguments. 
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    95
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    96
\begin{frame}[fragile]
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    97
\frametitle{Solution 3}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    98
\label{sec-7}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    99
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
   100
\begin{verbatim}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   101
def welcome(greet="Hello", name="World"):
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   102
    print greet, name
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   103
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   104
welcome()
367
2ca9b21ed8f9 reviewed advanced features of functions script.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 272
diff changeset
   105
\end{verbatim}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   106
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   107
\begin{frame}
272
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   108
\frametitle{Summary}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   109
\label{sec-8}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   110
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   111
  You should now be able to --
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   112
\begin{itemize}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   113
\item define functions with default arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   114
\item call functions using keyword arguments
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   115
\end{itemize}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   116
\end{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   117
\begin{frame}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   118
\frametitle{Thank you!}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   119
\label{sec-9}
08638b1e211e Slides for advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   120
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   121
  \begin{block}{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   122
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   123
  This spoken tutorial has been produced by the
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
  \textcolor{blue}{FOSSEE} team, which is funded by the 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
  \end{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   126
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   127
    \textcolor{blue}{National Mission on Education through \\
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   128
      Information \& Communication Technology \\ 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   129
      MHRD, Govt. of India}.
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   130
  \end{center}  
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   131
  \end{block}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   132
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   133
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   134
\end{document}