summaryrefslogtreecommitdiff
path: root/day1quiz2.tex
diff options
context:
space:
mode:
authorSantosh G. Vattam2009-11-11 17:08:32 +0530
committerSantosh G. Vattam2009-11-11 17:08:32 +0530
commitbf13c8137cdc1f37cb800a793b81ac1a037bf847 (patch)
tree8111c1e0d8dea27bf4720557364084787b443ee3 /day1quiz2.tex
parent5e35698923ce51294808056f84850b4971227abc (diff)
downloadworkshops-bf13c8137cdc1f37cb800a793b81ac1a037bf847.tar.gz
workshops-bf13c8137cdc1f37cb800a793b81ac1a037bf847.tar.bz2
workshops-bf13c8137cdc1f37cb800a793b81ac1a037bf847.zip
Updated the quiz tex files of both day 1 and day 2.
Diffstat (limited to 'day1quiz2.tex')
-rw-r--r--day1quiz2.tex253
1 files changed, 186 insertions, 67 deletions
diff --git a/day1quiz2.tex b/day1quiz2.tex
index 7b65c87..b7bfe2f 100644
--- a/day1quiz2.tex
+++ b/day1quiz2.tex
@@ -35,12 +35,13 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
-\title[Basic Python]{Python: Quiz}
+\title[Basic Python]{Python for science and engineering: Day 1, Quiz 2}
\author[FOSSEE Team] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {11, October 2009\\Day 2}
+\date[] {\today \\
+Day 1, quiz 2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -54,125 +55,243 @@
\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 }
+%% \begin{lstlisting}
+%% In []: x = array([[1,2,3,4],
+%% [3,4,2,5]])
+%% \end{lstlisting}
+%% What is the \lstinline+shape+ of this array?
+%% \end{frame}
+
+
\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
- >>> x = array([[1,2,3,4],[3,4,2,5]])
- >>> x.shape
- (2, 4)
+ In []: x = array([[1,2,3,4]])
\end{lstlisting}
-Change the shape of \lstinline+x+ to (4,2)
+How to change the third element (i.e.\ 3) of \lstinline+x+ to 0?
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
- >>> x = array([[1,2,3,4]])
+ In []: x = array([[1,2,3,4],
+ [3,4,2,5]])
+\end{lstlisting}
+How do you get the following slice of \lstinline+x+?
+\begin{lstlisting}
+array([[2,3],
+ [4,2]])
\end{lstlisting}
-How to change the third element of \lstinline+x+ to 0?
\end{frame}
+
+%% \begin{frame}
+%% \frametitle{\incqno }
+%% The file \lstinline+datafile.txt+ contains 3 columns of data. What
+%% command will you use to read the entire data file into an array?
+%% \end{frame}
+
+%% \begin{frame}
+%% \frametitle{\incqno }
+
+%% If the contents of the file \lstinline+datafile.txt+ is read into an
+%% $N\times3$ array called \lstinline+data+, how would you obtain the third
+%% column of this data?
+
+%% \end{frame}
+
\begin{frame}[fragile]
\frametitle{\incqno }
-What would be the result?
\begin{lstlisting}
- >>> y = arange(3)
- >>> x = linspace(0,3,3)
- >>> x-y
+ In []: x = array(([1,2,3,4],
+ [2,3,4,5]))
+ In []: x[-2][-3] = 4
+ In []: print x
\end{lstlisting}
+What will be printed?
\end{frame}
-\begin{frame}[fragile]
+
+%% \begin{frame}[fragile]
+%% \frametitle{\incqno }
+%% \begin{lstlisting}
+%% In []: x = arange(0, 1, 0.25)
+%% In []: print x
+%% \end{lstlisting}
+%% What will be printed?
+%% \end{frame}
+
+
+%% \begin{frame}[fragile]
+%% \frametitle{\incqno }
+%% \begin{lstlisting}
+%% from scipy.integrate import quad
+%% def f(x):
+%% res = x*cos(x)
+
+%% quad(f, 0, 1)
+%% \end{lstlisting}
+
+%% What changes will you make to the above code to make it work?
+%% \end{frame}
+
+%% \begin{frame}
+%% \frametitle{\incqno }
+%% What two commands will you use to create and evaluate a spline given
+%% some data?
+%% \end{frame}
+
+\begin{frame}
\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?
+What command will you use if you wish to integrate a system of ODEs?
\end{frame}
-\begin{frame}[fragile]
+\begin{frame}
\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}
+How do you calculate the roots of the polynomial, $y = 1 + 6x + 8x^2 +
+x^3$?
\end{frame}
-\begin{frame}[fragile]
+\begin{frame}
\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}
+
+Two arrays \lstinline+a+ and \lstinline+b+ are numerically almost equal, what command
+do you use to check if this is true?
+
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
- >>> x = array(([1,2,3,4],[2,3,4,5]))
- >>> x[-2][-3] = 4
- >>> x
+In []: marks = [10, 20, 30, 50, 55,
+ 75, 83]
\end{lstlisting}
-What will be printed?
+How will you convert the list \texttt{marks} to an \alert{array}?
\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
+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}
- >>> line = plot(x, sin(x))
+In []: a = array([[1, 2],
+ [3, 4]])
\end{lstlisting}
-Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2.
+How do you get the transpose of this array?
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
-What would be the output?
\begin{lstlisting}
- >>> x = arange(9)
- >>> y = arange(9.)
- >>> x == y
+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}
\end{document}
+%% \begin{frame}[fragile]
+%% \frametitle{\incqno }
+%% What would be the result?
+%% \begin{lstlisting}
+%% In []: x
+%% array([[0, 1, 2],
+%% [3, 4, 5],
+%% [6, 7, 8]])
+%% In []: x[::-1,:]
+%% \end{lstlisting}
+%% Hint:
+%% \begin{lstlisting}
+%% In []: x = arange(9)
+%% In []: x[::-1]
+%% array([8, 7, 6, 5, 4, 3, 2, 1, 0])
+%% \end{lstlisting}
+%% \end{frame}
+
+%% \begin{frame}[fragile]
+%% \frametitle{\incqno }
+%% What would be the result?
+%% \begin{lstlisting}
+%% In []: y = arange(3)
+%% In []: x = linspace(0,3,3)
+%% In []: x-y
+%% \end{lstlisting}
+%% \end{frame}
+
+%% \begin{frame}[fragile]
+%% \frametitle{\incqno }
+%% \begin{lstlisting}
+%% In []: 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 }
+%% What would be the output?
+%% \begin{lstlisting}
+%% In []: y = arange(4)
+%% In []: x = array(([1,2,3,2],[1,3,6,0]))
+%% In []: x + y
+%% \end{lstlisting}
+%% \end{frame}
+
+%% \begin{frame}[fragile]
+%% \frametitle{\incqno }
+%% \begin{lstlisting}
+%% In []: 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}
+%% In []: x = arange(9)
+%% In []: y = arange(9.)
+%% In []: x == y
+%% \end{lstlisting}
+%% \end{frame}
+