--- a/day1/session4.tex Mon Oct 26 20:44:54 2009 +0530
+++ b/day1/session4.tex Tue Oct 27 10:59:11 2009 +0530
@@ -249,9 +249,55 @@
\end{frame}
\begin{frame}[fragile]
+\frametitle{Functions - Calling them}
+\begin{lstlisting}
+In [15]: f()
+---------------------------------------
+\end{lstlisting}
+\alert{\typ{TypeError:}}\typ{f() takes exactly 1 argument}
+\typ{(0 given)}
+\begin{lstlisting}
+In []: f(0)
+Out[]: 0.0
+In []: f(1)
+Out[]: 1.8414709848078965
+\end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+\frametitle{Functions - Default Arguments}
+\begin{lstlisting}
+In []: def f(x=1):
+ return sin(x)+x**2
+In []: f(10)
+Out[]: 99.455978889110625
+In []: f(1)
+Out[]: 1.8414709848078965
+In []: f()
+Out[]: 1.8414709848078965
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Functions - Keyword Arguments}
+\begin{lstlisting}
+In []: def f(x=1, y=pi):
+ return sin(y)+x**2
+In []: f()
+Out[]: 1.0000000000000002
+In []: f(2)
+Out[]: 4.0
+In []: f(y=2)
+Out[]: 1.9092974268256817
+In []: f(y=pi/2,x=0)
+Out[]: 1.0
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
\frametitle{More on functions}
\begin{itemize}
- \item Support default and keyword arguments
\item Scope of variables in the function is local
\item Mutable items are \alert{passed by reference}
\item First line after definition may be a documentation string
@@ -262,6 +308,13 @@
\end{itemize}
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Quadrature \ldots}
+\begin{lstlisting}
+In []: integrate.quad(f, 0, 1)
+\end{lstlisting}
+Returns the integral and an estimate of the absolute error in the result.
+\end{frame}
\subsection{ODEs}