58 \item University/College/Company: |
56 \item University/College/Company: |
59 \item Student/Teacher/Professional: |
57 \item Student/Teacher/Professional: |
60 \end{itemize} |
58 \end{itemize} |
61 \end{frame} |
59 \end{frame} |
62 |
60 |
63 \begin{frame}[fragile] |
|
64 \frametitle{\incqno } |
|
65 Describe the plot produced by the following: |
|
66 |
|
67 \begin{lstlisting} |
|
68 In []: x = linspace(0, 2*pi) |
|
69 In []: plot(x, cos(x), 'go') |
|
70 \end{lstlisting} |
|
71 \end{frame} |
|
72 |
|
73 \begin{frame} |
|
74 \frametitle{\incqno } |
|
75 How will you plot the previous graph with line width set to 3? How will |
|
76 you set the $x$ and $y$ labels of the plot? |
|
77 \end{frame} |
|
78 |
|
79 \begin{frame} |
|
80 \frametitle{\incqno } |
|
81 How will you set the x and y axis limits so that the region of interest |
|
82 is in the rectangle $(0, -1.5)$ (left bottom coordinate) and $(2\pi, |
|
83 1.5)$ (right top coordinate)? |
|
84 \end{frame} |
|
85 |
|
86 \begin{frame} |
|
87 \frametitle{\incqno } |
|
88 A sample line from a Comma Separated Values (CSV) file:\\ |
|
89 \vspace*{0.2in} |
|
90 \emph{Rossum, Guido, 42, 56, 34, 54}\\ |
|
91 \vspace*{0.2in} |
|
92 What code would you use to separate the line into fields? |
|
93 \end{frame} |
|
94 |
|
95 \begin{frame}[fragile] |
|
96 \frametitle{\incqno } |
|
97 \begin{lstlisting} |
|
98 In []: a = [1, 2, 5, 9] |
|
99 In []: a[0:-1] |
|
100 \end{lstlisting} |
|
101 What is the output? |
|
102 \end{frame} |
|
103 |
|
104 \begin{frame} |
|
105 \frametitle{\incqno } |
|
106 How do you combine two lists \emph{a} and \emph{b} to produce one list? |
|
107 \end{frame} |
|
108 |
|
109 \begin{frame}[fragile] |
|
110 \frametitle{\incqno } |
|
111 \begin{lstlisting} |
|
112 In []: a = [1, 2, 5, 9] |
|
113 \end{lstlisting} |
|
114 How do you add the value 10 to the end of this list? |
|
115 \end{frame} |
|
116 |
|
117 \begin{frame}[fragile] |
|
118 \frametitle{\incqno } |
|
119 \begin{lstlisting} |
|
120 In []: a = [1, 2, 5, 9] |
|
121 \end{lstlisting} |
|
122 How do you find the length of this list? |
|
123 \end{frame} |
|
124 |
|
125 \begin{frame}[fragile] |
|
126 \frametitle{\incqno } |
|
127 \begin{lstlisting} |
|
128 In [1]: d = { |
|
129 'a': 1, |
|
130 'b': 2 |
|
131 } |
|
132 In [2]: print d['c'] |
|
133 \end{lstlisting} |
|
134 What is the output? |
|
135 \end{frame} |
|
136 |
|
137 %% \begin{frame}[fragile] |
|
138 %% \frametitle{\incqno } |
|
139 %% \begin{lstlisting} |
|
140 %% for x in "abcd": |
|
141 %% print x |
|
142 |
|
143 %% a |
|
144 %% b |
|
145 %% c |
|
146 %% d |
|
147 %% \end{lstlisting} |
|
148 %% How do you get the following output? |
|
149 %% \begin{lstlisting} |
|
150 %% 0 a |
|
151 %% 1 b |
|
152 %% 2 c |
|
153 %% 3 d |
|
154 %% \end{lstlisting} |
|
155 %% \end{frame} |
|
156 |
|
157 \begin{frame} |
|
158 \frametitle{\incqno } |
|
159 What ipython magic command do you use to obtain the lines of code you have already typed in the interpreter? What command do you use to save them? |
|
160 \end{frame} |
|
161 |
|
162 \begin{frame} |
|
163 \begin{lstlisting} |
|
164 In []: sc = {'A': 10, 'B': 20, |
|
165 'C': 70} |
|
166 \end{lstlisting} |
|
167 Given the above dictionary, what command will you give to plot a |
|
168 pie-chart? |
|
169 \end{frame} |
|
170 |
|
171 |
|
172 \begin{frame}[fragile] |
|
173 \frametitle{\incqno } |
|
174 \begin{lstlisting} |
|
175 In []: marks = [10, 20, 30, 50, 55, |
|
176 75, 83] |
|
177 \end{lstlisting} |
|
178 |
|
179 Given the above marks, how will you calculate the \alert{mean} and |
|
180 \alert{standard deviation}? |
|
181 \end{frame} |
|
182 |
|
183 %\begin{frame}[fragile] |
|
184 %\frametitle{\incqno } |
|
185 %\begin{lstlisting} |
|
186 %In []: marks = [10, 20, 30, 50, 55, |
|
187 % 75, 83] |
|
188 %\end{lstlisting} |
|
189 %How will you convert the list \texttt{marks} to an \alert{array}? |
|
190 %\end{frame} |
|
191 |
|
192 %% \begin{frame}[fragile] |
|
193 %% \frametitle{\incqno } |
|
194 %% \begin{lstlisting} |
|
195 %% In []: a = array([[1, 2], |
|
196 %% [3, 4]]) |
|
197 %% In []: a[1,0] = 0 |
|
198 %% \end{lstlisting} |
|
199 %% What is the resulting matrix? |
|
200 %% \end{frame} |
|
201 |
|
202 %% \begin{frame}[fragile] |
|
203 %% \frametitle{\incqno } |
|
204 %% \begin{lstlisting} |
|
205 %% In []: a = array([[1, 2], |
|
206 %% [3, 4]]) |
|
207 %% \end{lstlisting} |
|
208 %% How do you get the transpose of this array? |
|
209 %% \end{frame} |
|
210 |
|
211 %% \begin{frame}[fragile] |
|
212 %% \frametitle{\incqno } |
|
213 %% \begin{lstlisting} |
|
214 %% In []: a = array([[1, 2], |
|
215 %% [3, 4]]) |
|
216 %% In []: b = array([[1, 1], |
|
217 %% [2, 2]]) |
|
218 %% In []: a*b |
|
219 %% \end{lstlisting} |
|
220 %% What does this produce? |
|
221 %% \end{frame} |
|
222 |
|
223 %% \begin{frame} |
|
224 %% \frametitle{\incqno } |
|
225 %% What command do you use to find the inverse of a matrix and its |
|
226 %% eigenvalues? |
|
227 %% \end{frame} |
|
228 |
|
229 %% \begin{frame} |
|
230 %% \frametitle{\incqno } |
|
231 %% Given a 4x4 matrix \texttt{A} and a 4-vector \texttt{b}, what command do |
|
232 %% you use to solve for the equation \\ |
|
233 %% \texttt{Ax = b}? |
|
234 %% \end{frame} |
|
235 |
|
236 \begin{frame} |
|
237 \frametitle{\incqno } |
|
238 Write the code to read a file \texttt{data.txt} and print each line of it? |
|
239 \end{frame} |
|
240 |
|
241 \begin{frame}[fragile] |
|
242 \frametitle{\incqno } |
|
243 What is the output of: |
|
244 \begin{lstlisting} |
|
245 In []: x=linspace(0 , 2 * pi) |
|
246 In []: plot(x, cos(x),'go') |
|
247 \end{lstlisting} |
|
248 \end{frame} |
|
249 |
|
250 \begin{frame} |
|
251 \frametitle{\incqno } |
|
252 Draw a plot with line width 3. |
|
253 \end{frame} |
|
254 |
|
255 \begin{frame} |
|
256 \frametitle{\incqno } |
|
257 Setting x and y axis limits. |
|
258 \end{frame} |
|
259 |
|
260 \begin{frame}[fragile] |
|
261 \frametitle{\incqno } |
|
262 The following code snippet has an error/bug: |
|
263 \begin{lstlisting} |
|
264 In []: l = [0.1, 0.2, 0.3, 0.4] |
|
265 In []: t = [0.69, 0.90, 1.19, 1.30] |
|
266 In []: tsq = [] |
|
267 In []: for time in t: |
|
268 ....: tsq.append(time*time) |
|
269 ....: plot(l, tsq) |
|
270 \end{lstlisting} |
|
271 |
|
272 What is the error? How do you fix it? |
|
273 \end{frame} |
|
274 |
|
275 \end{document} |
61 \end{document} |