diff options
Diffstat (limited to 'day1quiz1.tex')
-rw-r--r-- | day1quiz1.tex | 181 |
1 files changed, 130 insertions, 51 deletions
diff --git a/day1quiz1.tex b/day1quiz1.tex index e669acf..b2d5f6e 100644 --- a/day1quiz1.tex +++ b/day1quiz1.tex @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Tutorial slides on Python. +% Quiz slides day 1 quiz 1 % % Author: FOSSEE <info at fossee dot in> % Copyright (c) 2005-2009, FOSSEE Team @@ -35,12 +35,12 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Title page -\title[Basic Python]{Python: Quiz} +\title[Basic Python]{Python for science and engineering: Day 1, Quiz 1} \author[FOSSEE Team] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {31, October 2009\\Day 1, Quiz 1} +\date[] {\today \\Day 1, Quiz 1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -54,107 +54,186 @@ \frametitle{Write your details...} On the top right hand corner please write down the following: \begin{itemize} - \item Name: - \item Affliation: - \item Occupation: + \item Name: + \item University/College/Company: + \item Student/Teacher/Professional: \end{itemize} \end{frame} +\begin{frame}[fragile] +\frametitle{\incqno } +Describe the plot produced by the following: + +\begin{lstlisting} +In []: x = linspace(0, 2*pi) +In []: plot(x, cos(x), 'go') +\end{lstlisting} +\end{frame} + +\begin{frame} +\frametitle{\incqno } +How will you plot the previous graph with line width set to 3? How will +you set the $x$ and $y$ labels of the plot? +\end{frame} + +\begin{frame} +\frametitle{\incqno } +How will you set the x and y axis limits so that the region of interest +is in the rectangle $(0, -1.5)$ (left bottom coordinate) and $(2\pi, +1.5)$ (right top coordinate)? +\end{frame} + \begin{frame} \frametitle{\incqno } A sample line from a Comma Separated Values (CSV) file:\\ \vspace*{0.2in} \emph{Rossum, Guido, 42, 56, 34, 54}\\ \vspace*{0.2in} - What method would you use to separate the line into fields? + What code would you use to separate the line into fields? \end{frame} \begin{frame}[fragile] \frametitle{\incqno } \begin{lstlisting} - In [1]: a = [1, 2, 5, 9] - In [2]: a[:-1] + In []: a = [1, 2, 5, 9] + In []: a[0:-1] \end{lstlisting} What is the output? \end{frame} \begin{frame} \frametitle{\incqno } - How do you combine the two lists \emph{a} and \emph{b}? + How do you combine two lists \emph{a} and \emph{b} to produce one list? \end{frame} \begin{frame}[fragile] \frametitle{\incqno } \begin{lstlisting} - In [1]: d = { - 'a': 1, - 'b': 2 - } - In [2]: print d['c'] + In []: a = [1, 2, 5, 9] \end{lstlisting} - What is the output? + How do you add the value 10 to the end of this list? \end{frame} \begin{frame}[fragile] \frametitle{\incqno } \begin{lstlisting} - for x in "abcd": - print x - - a - b - c - d + In []: a = [1, 2, 5, 9] \end{lstlisting} - How do you get the following output? + How do you find the length of this list? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } \begin{lstlisting} - 0 a - 1 b - 2 c - 3 d + In [1]: d = { + 'a': 1, + 'b': 2 + } + In [2]: print d['c'] \end{lstlisting} + What is the output? \end{frame} +%% \begin{frame}[fragile] +%% \frametitle{\incqno } +%% \begin{lstlisting} +%% for x in "abcd": +%% print x + +%% a +%% b +%% c +%% d +%% \end{lstlisting} +%% How do you get the following output? +%% \begin{lstlisting} +%% 0 a +%% 1 b +%% 2 c +%% 3 d +%% \end{lstlisting} +%% \end{frame} + \begin{frame}[fragile] \frametitle{\incqno } -What would be the result? \begin{lstlisting} - In [1]: x - array([[0, 1, 2], - [3, 4, 5], - [6, 7, 8]]) - In [2]: x[::-1,:] +In []: sc = {'A': 10, 'B': 20, + 'C': 70} \end{lstlisting} +Given the above dictionary, what command will you give to plot a +pie-chart? \end{frame} -\begin{frame} -\frametitle{\incqno } -How to read and print each line of a file. -\end{frame} - -\begin{frame} -\frametitle{\incqno } -How to get list of third column of a data file. -\end{frame} \begin{frame}[fragile] \frametitle{\incqno } -What is the output of: \begin{lstlisting} -In []: x=linspace(0 , 2 * pi) -In []: plot(x, cos(x),'go') +In []: marks = [10, 20, 30, 50, 55, + 75, 83] \end{lstlisting} -\end{frame} -\begin{frame} -\frametitle{\incqno } -Draw a plot with line width 3. +Given the above marks, how will you calculate the \alert{mean} and +\alert{standard deviation}? \end{frame} +%\begin{frame}[fragile] +%\frametitle{\incqno } +%\begin{lstlisting} +%In []: marks = [10, 20, 30, 50, 55, +% 75, 83] +%\end{lstlisting} +%How will you convert the list \texttt{marks} to an \alert{array}? +%\end{frame} + +%% \begin{frame}[fragile] +%% \frametitle{\incqno } +%% \begin{lstlisting} +%% In []: a = array([[1, 2], +%% [3, 4]]) +%% In []: a[1,0] = 0 +%% \end{lstlisting} +%% What is the resulting matrix? +%% \end{frame} + +%% \begin{frame}[fragile] +%% \frametitle{\incqno } +%% \begin{lstlisting} +%% In []: a = array([[1, 2], +%% [3, 4]]) +%% \end{lstlisting} +%% How do you get the transpose of this array? +%% \end{frame} + +%% \begin{frame}[fragile] +%% \frametitle{\incqno } +%% \begin{lstlisting} +%% In []: a = array([[1, 2], +%% [3, 4]]) +%% In []: b = array([[1, 1], +%% [2, 2]]) +%% In []: a*b +%% \end{lstlisting} +%% What does this produce? +%% \end{frame} + +%% \begin{frame} +%% \frametitle{\incqno } +%% What command do you use to find the inverse of a matrix and its +%% eigenvalues? +%% \end{frame} + +%% \begin{frame} +%% \frametitle{\incqno } +%% Given a 4x4 matrix \texttt{A} and a 4-vector \texttt{b}, what command do +%% you use to solve for the equation \\ +%% \texttt{Ax = b}? +%% \end{frame} + \begin{frame} \frametitle{\incqno } -Setting x and y axis limits. +Write the code to read a file \texttt{data.txt} and print each line of it? \end{frame} + \end{document} |