diff options
author | Puneeth Chaganti | 2009-10-12 16:46:47 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2009-10-12 16:46:47 +0530 |
commit | 13d8dc6f3db4880e6550851481265aac7f2e6e35 (patch) | |
tree | ebed4a5c082f9699dde75e76a53ceb72203983d5 | |
parent | ab28c4143ac552558a23d054fd947cc01ebb5e3c (diff) | |
download | workshops-more-scipy-13d8dc6f3db4880e6550851481265aac7f2e6e35.tar.gz workshops-more-scipy-13d8dc6f3db4880e6550851481265aac7f2e6e35.tar.bz2 workshops-more-scipy-13d8dc6f3db4880e6550851481265aac7f2e6e35.zip |
Added Day2 Quiz.
-rw-r--r-- | quiz-day2.tex | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/quiz-day2.tex b/quiz-day2.tex new file mode 100644 index 0000000..7b65c87 --- /dev/null +++ b/quiz-day2.tex @@ -0,0 +1,178 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Tutorial slides on Python. +% +% Author: FOSSEE <info at fossee dot in> +% Copyright (c) 2005-2009, FOSSEE Team +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\documentclass[14pt,compress]{beamer} + +\mode<presentation> +{ + \useoutertheme{split} + \setbeamercovered{transparent} +} + +\definecolor{darkgreen}{rgb}{0,0.5,0} + +\usepackage{listings} +\lstset{language=Python, + basicstyle=\ttfamily\bfseries, + commentstyle=\color{red}\itshape, + stringstyle=\color{darkgreen}, + showstringspaces=false, + keywordstyle=\color{blue}\bfseries} + +\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Macros + +\newcounter{qno} +\setcounter{qno}{0} +\newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Title page +\title[Basic Python]{Python: Quiz} + +\author[FOSSEE Team] {FOSSEE} + +\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} +\date[] {11, October 2009\\Day 2} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\begin{document} + +\begin{frame} + \titlepage +\end{frame} + +\begin{frame} + \frametitle{Write your details...} +On the top right hand corner please write down the following: + \begin{itemize} + \item Name: + \item Affliation: + \item Occupation: + \end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([[1,2,3,4],[3,4,2,5]]) + >>> x.shape + (2, 4) +\end{lstlisting} +Change the shape of \lstinline+x+ to (4,2) +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([[1,2,3,4]]) +\end{lstlisting} +How to change the third element of \lstinline+x+ to 0? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + >>> y = arange(3) + >>> x = linspace(0,3,3) + >>> x-y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([0, 1, 2, 3]) + >>> x.shape = 2,2 + >>> x + array([[0, 1], + [2, 3]]) + >>> x[::2,::2] +\end{lstlisting} +What is the output? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + >>> x + array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) + >>> x[::-1,:] +\end{lstlisting} +Hint: +\begin{lstlisting} + >>> x = arange(9) + >>> x[::-1] + array([8, 7, 6, 5, 4, 3, 2, 1, 0]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x + array([[ 0, 1, 2, 3], + [ 4, 5, 6, 7], + [ 8, 9, 10, 11], + [12, 13, 14, 15]]) +\end{lstlisting} +How will you get the following \lstinline+x+? +\begin{lstlisting} + array([[ 5, 7], + [ 9, 11]]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array(([1,2,3,4],[2,3,4,5])) + >>> x[-2][-3] = 4 + >>> x +\end{lstlisting} +What will be printed? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the output? +\begin{lstlisting} + >>> y = arange(4) + >>> x = array(([1,2,3,2],[1,3,6,0])) + >>> x + y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> line = plot(x, sin(x)) +\end{lstlisting} +Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2. +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the output? +\begin{lstlisting} + >>> x = arange(9) + >>> y = arange(9.) + >>> x == y +\end{lstlisting} +\end{frame} + + +\end{document} + |