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