day1quiz2.tex
changeset 343 adb85e126341
parent 306 57291186d598
equal deleted inserted replaced
342:f91a75802238 343:adb85e126341
    59     \item University/College/Company:
    59     \item University/College/Company:
    60     \item Student/Teacher/Professional:
    60     \item Student/Teacher/Professional:
    61   \end{itemize}
    61   \end{itemize}
    62 \end{frame}
    62 \end{frame}
    63 
    63 
    64 %% \begin{frame}[fragile]
    64 \end{document}
    65 %% \frametitle{\incqno }
       
    66 %% \begin{lstlisting}
       
    67 %%   In []: x = array([[1,2,3,4],
       
    68 %%                     [3,4,2,5]])
       
    69 %% \end{lstlisting}
       
    70 %% What is the \lstinline+shape+ of this array?
       
    71 %% \end{frame}
       
    72 
    65 
    73 
    66 
    74 \begin{frame}[fragile]
       
    75 \frametitle{\incqno }
       
    76 \begin{lstlisting}
       
    77   In []: x = array([[1,2,3,4]])
       
    78 \end{lstlisting}
       
    79 How to change the third element (i.e.\ 3) of \lstinline+x+ to 0?
       
    80 \end{frame}
       
    81 
       
    82 \begin{frame}[fragile]
       
    83 \frametitle{\incqno }
       
    84 \begin{lstlisting}
       
    85   In []: x = array([[1,2,3,4],
       
    86                     [3,4,2,5]])
       
    87 \end{lstlisting}
       
    88 How do you get the following slice of \lstinline+x+?
       
    89 \begin{lstlisting}
       
    90 array([[2,3],
       
    91        [4,2]])
       
    92 \end{lstlisting}
       
    93 \end{frame}
       
    94 
       
    95 
       
    96 %% \begin{frame}
       
    97 %% \frametitle{\incqno }
       
    98 %% The file \lstinline+datafile.txt+ contains 3 columns of data.  What
       
    99 %% command will you use to read the entire data file into an array?
       
   100 %% \end{frame}
       
   101 
       
   102 %% \begin{frame}
       
   103 %% \frametitle{\incqno }
       
   104 
       
   105 %% If the contents of the file \lstinline+datafile.txt+ is read into an
       
   106 %% $N\times3$ array called \lstinline+data+, how would you obtain the third
       
   107 %% column of this data?
       
   108 
       
   109 %% \end{frame}
       
   110 
       
   111 \begin{frame}[fragile]
       
   112 \frametitle{\incqno }
       
   113 \begin{lstlisting}
       
   114   In []: x = array(([1,2,3,4],
       
   115                     [2,3,4,5]))
       
   116   In []: x[-2][-3] = 4
       
   117   In []: print x
       
   118 \end{lstlisting}
       
   119 What will be printed?
       
   120 \end{frame}
       
   121 
       
   122 
       
   123 %% \begin{frame}[fragile]
       
   124 %% \frametitle{\incqno }
       
   125 %% \begin{lstlisting}
       
   126 %%   In []: x = arange(0, 1, 0.25)
       
   127 %%   In []: print x
       
   128 %% \end{lstlisting}
       
   129 %% What will be printed?
       
   130 %% \end{frame}
       
   131 
       
   132 
       
   133 %% \begin{frame}[fragile]
       
   134 %% \frametitle{\incqno }
       
   135 %% \begin{lstlisting}
       
   136 %% from scipy.integrate import quad
       
   137 %% def f(x):
       
   138 %%     res = x*cos(x)
       
   139 
       
   140 %% quad(f, 0, 1)
       
   141 %% \end{lstlisting}
       
   142 
       
   143 %% What changes will you make to the above code to make it work?
       
   144 %% \end{frame}
       
   145 
       
   146 %% \begin{frame}
       
   147 %% \frametitle{\incqno }
       
   148 %% What two commands will you use to create and evaluate a spline given
       
   149 %% some data?
       
   150 %% \end{frame}
       
   151 
       
   152 \begin{frame}
       
   153 \frametitle{\incqno }
       
   154 What command will you use if you wish to integrate a system of ODEs?
       
   155 \end{frame}
       
   156 
       
   157 \begin{frame}
       
   158 \frametitle{\incqno }
       
   159 How do you calculate the roots of the polynomial, $y = 1 + 6x + 8x^2 +
       
   160 x^3$?
       
   161 \end{frame}
       
   162 
       
   163 \begin{frame}
       
   164 \frametitle{\incqno }
       
   165 
       
   166 Two arrays \lstinline+a+ and \lstinline+b+ are numerically almost equal, what command
       
   167 do you use to check if this is true?
       
   168 
       
   169 \end{frame}
       
   170 
       
   171 \begin{frame}[fragile]
       
   172 \frametitle{\incqno }
       
   173 \begin{lstlisting}
       
   174 In []: marks = [10, 20, 30, 50, 55, 
       
   175                75, 83] 
       
   176 \end{lstlisting}
       
   177 How will you convert the list \texttt{marks} to an \alert{array}?
       
   178 \end{frame}
       
   179 
       
   180 \begin{frame}[fragile]
       
   181 \frametitle{\incqno }
       
   182 \begin{lstlisting}
       
   183 In []: a = array([[1, 2],
       
   184                   [3, 4]])
       
   185 In []: a[1,0] = 0
       
   186 \end{lstlisting}
       
   187 What is the resulting matrix?
       
   188 \end{frame}
       
   189 
       
   190 \begin{frame}[fragile]
       
   191 \frametitle{\incqno }
       
   192 \begin{lstlisting}
       
   193 In []: a = array([[1, 2],
       
   194                   [3, 4]])
       
   195 \end{lstlisting}
       
   196 How do you get the transpose of this array?
       
   197 \end{frame}
       
   198 
       
   199 \begin{frame}[fragile]
       
   200 \frametitle{\incqno }
       
   201 \begin{lstlisting}
       
   202 In []: a = array([[1, 2],
       
   203                   [3, 4]])
       
   204 In []: b = array([[1, 1],
       
   205                   [2, 2]])
       
   206 In []: a*b
       
   207 \end{lstlisting}
       
   208 What does this produce?
       
   209 \end{frame}
       
   210 
       
   211 \begin{frame}
       
   212 \frametitle{\incqno }
       
   213 What command do you use to find the inverse of a matrix and its
       
   214 eigenvalues?
       
   215 \end{frame}
       
   216 
       
   217 \begin{frame}
       
   218 \frametitle{\incqno }
       
   219 Given a 4x4 matrix \texttt{A} and a 4-vector \texttt{b}, what command do
       
   220 you use to solve for the equation \\
       
   221 \texttt{Ax = b}?
       
   222 \end{frame}
       
   223 
       
   224 \end{document}
       
   225 
       
   226 %% \begin{frame}[fragile]
       
   227 %% \frametitle{\incqno }
       
   228 %% What would be the result?
       
   229 %% \begin{lstlisting}
       
   230 %%   In []: x
       
   231 %%   array([[0, 1, 2],
       
   232 %%          [3, 4, 5],
       
   233 %%          [6, 7, 8]])
       
   234 %%   In []: x[::-1,:]
       
   235 %% \end{lstlisting}
       
   236 %% Hint:
       
   237 %% \begin{lstlisting}
       
   238 %%   In []: x = arange(9)
       
   239 %%   In []: x[::-1]
       
   240 %%   array([8, 7, 6, 5, 4, 3, 2, 1, 0])
       
   241 %% \end{lstlisting}
       
   242 %% \end{frame}
       
   243 
       
   244 %% \begin{frame}[fragile]
       
   245 %% \frametitle{\incqno }
       
   246 %% What would be the result?
       
   247 %% \begin{lstlisting}
       
   248 %%   In []: y = arange(3)
       
   249 %%   In []: x = linspace(0,3,3)
       
   250 %%   In []: x-y
       
   251 %% \end{lstlisting}
       
   252 %% \end{frame}
       
   253 
       
   254 %% \begin{frame}[fragile]
       
   255 %% \frametitle{\incqno }
       
   256 %% \begin{lstlisting}
       
   257 %%   In []: x
       
   258 %%   array([[ 0, 1, 2, 3],
       
   259 %%          [ 4, 5, 6, 7],
       
   260 %%          [ 8, 9, 10, 11],
       
   261 %%          [12, 13, 14, 15]])
       
   262 %% \end{lstlisting}
       
   263 %% How will you get the following \lstinline+x+?
       
   264 %% \begin{lstlisting}
       
   265 %%   array([[ 5, 7],
       
   266 %%          [ 9, 11]])
       
   267 %% \end{lstlisting}
       
   268 %% \end{frame}
       
   269 
       
   270 %% \begin{frame}[fragile]
       
   271 %% \frametitle{\incqno }
       
   272 %% What would be the output?
       
   273 %% \begin{lstlisting}
       
   274 %%   In []: y = arange(4)
       
   275 %%   In []: x = array(([1,2,3,2],[1,3,6,0]))
       
   276 %%   In []: x + y
       
   277 %% \end{lstlisting}
       
   278 %% \end{frame}
       
   279 
       
   280 %% \begin{frame}[fragile]
       
   281 %% \frametitle{\incqno }
       
   282 %% \begin{lstlisting}
       
   283 %%   In []: line = plot(x, sin(x))
       
   284 %% \end{lstlisting}
       
   285 %% Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2.
       
   286 %% \end{frame}
       
   287 
       
   288 %% \begin{frame}[fragile]
       
   289 %% \frametitle{\incqno }
       
   290 %% What would be the output?
       
   291 %% \begin{lstlisting}
       
   292 %%   In []: x = arange(9)
       
   293 %%   In []: y = arange(9.)
       
   294 %%   In []: x == y
       
   295 %% \end{lstlisting}
       
   296 %% \end{frame}
       
   297