# HG changeset patch # User Puneeth Chaganti # Date 1291920371 -19800 # Node ID f9417abb23a6f79bc486a090aedcd0a1929ca3f6 # Parent db7b234655723586d1ff68cc3acc66baa0d92179 Moved exercises and other minor changes in day2/session3. diff -r db7b23465572 -r f9417abb23a6 day2/session3.tex --- a/day2/session3.tex Fri Dec 10 00:04:59 2010 +0530 +++ b/day2/session3.tex Fri Dec 10 00:16:11 2010 +0530 @@ -51,7 +51,7 @@ \setcounter{time}{0} \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} -\newcommand{\typ}[1]{\lstinline{#1}} +\newcommand{\typ}[1]{\textbf{\texttt{#1}}} \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } @@ -193,6 +193,22 @@ \end{lstlisting} \end{frame} +\subsection{Exercises} +\begin{frame}{Problem 3.1} + Write a function to return the gcd of two numbers. +\end{frame} + +\begin{frame}{Problem 3.2} +Write a program to print all primitive pythagorean triads (a, b, c) where a, b are in the range 1---100 \\ +A pythagorean triad $(a,b,c)$ has the property $a^2 + b^2 = c^2$.\\By primitive we mean triads that do not `depend' on others. For example, (4,3,5) is a variant of (3,4,5) and hence is not primitive. And (10,24,26) is easily derived from (5,12,13) and is also not primitive. +\end{frame} + +\begin{frame}{Problem 3.3} + Write a program that generates a list of all four digit numbers that have all their digits even and are perfect squares.\newline\\\emph{For example, the output should include 6400 but not 8100 (one digit is odd) or 4248 (not a perfect square).} + +% \inctime{15} +\end{frame} + \subsection{Default arguments} \begin{frame}[fragile] \frametitle{Functions: default arguments} @@ -267,28 +283,12 @@ \item Refer here: \url{http://docs.python.org/library/functions.html} \end{itemize} - \inctime{10} -\end{frame} - -\subsection{Exercises} -\begin{frame}{Problem set 3: Problem 3.1} - Write a function to return the gcd of two numbers. -\end{frame} - -\begin{frame}{Problem 3.2} -Write a program to print all primitive pythagorean triads (a, b, c) where a, b are in the range 1---100 \\ -A pythagorean triad $(a,b,c)$ has the property $a^2 + b^2 = c^2$.\\By primitive we mean triads that do not `depend' on others. For example, (4,3,5) is a variant of (3,4,5) and hence is not primitive. And (10,24,26) is easily derived from (5,12,13) and is also not primitive. -\end{frame} - -\begin{frame}{Problem 3.3} - Write a program that generates a list of all four digit numbers that have all their digits even and are perfect squares.\newline\\\emph{For example, the output should include 6400 but not 8100 (one digit is odd) or 4248 (not a perfect square).} - -\inctime{15} +% \inctime{10} \end{frame} \section{Modules} \begin{frame}[fragile] - \frametitle{\texttt{from} \ldots \texttt{import} magic} + \frametitle{\typ{from} \ldots \typ{import} magic} \begin{lstlisting} from scipy.integrate import odeint @@ -384,7 +384,7 @@ \end{frame} \begin{frame}[fragile] - \frametitle{\texttt{from} \ldots \texttt{import} - conventional way!} + \frametitle{\typ{from} \ldots \typ{import} - conventional way!} \small \begin{lstlisting} from scipy import linspace, pi, sin @@ -404,7 +404,7 @@ \end{frame} \begin{frame}[fragile] - \frametitle{\texttt{from} \ldots \texttt{import} - conventional way!} + \frametitle{\typ{from} \ldots \typ{import} - conventional way!} \small \begin{lstlisting} import scipy @@ -423,7 +423,7 @@ \end{frame} \begin{frame}[fragile] - \frametitle{\texttt{import} - the community convention} + \frametitle{\typ{import} - the community convention} \begin{lstlisting} import numpy as np @@ -452,19 +452,19 @@ \item Check out the Python Library reference: \url{http://docs.python.org/library/} \end{itemize} -\inctime{5} +% \inctime{5} \end{frame} \begin{frame}[fragile] \frametitle{Modules of special interest} \begin{description}[matplotlibfor2d] - \item[\texttt{pylab}] Easy, interactive, 2D plotting + \item[\typ{pylab}] Easy, interactive, 2D plotting - \item[\texttt{scipy}] arrays, statistics, optimization, integration, linear + \item[\typ{scipy}] arrays, statistics, optimization, integration, linear algebra, Fourier transforms, signal and image processing, genetic algorithms, ODE solvers, special functions, and more - \item[\texttt{Mayavi}] Easy, interactive, 3D plotting + \item[\typ{mayavi}] Easy, interactive, 3D plotting \end{description} \end{frame} @@ -543,12 +543,14 @@ for line in urllib2.urlopen('http://site.com'): print line \end{lstlisting} - \inctime{10} +% \inctime{10} \end{frame} \begin{frame} \frametitle{What did we learn?} \begin{itemize} + \item Functions: Definition + \item Functions: Docstrings \item Functions: Default and Keyword arguments \item Modules \item Objects