day1/day1quiz1.tex
changeset 354 5dc6c3673f9d
parent 349 58366fe3839b
child 371 9956a5bcd0f5
equal deleted inserted replaced
353:8999d0a3fc9d 354:5dc6c3673f9d
    56     \item University/College/Company:
    56     \item University/College/Company:
    57     \item Student/Teacher/Professional:
    57     \item Student/Teacher/Professional:
    58   \end{itemize}
    58   \end{itemize}
    59 \end{frame}
    59 \end{frame}
    60 
    60 
       
    61 \begin{frame}[fragile]
       
    62 \frametitle{\incqno }
       
    63 Draw (roughly) the plot obtained by the following:
       
    64 \begin{lstlisting}
       
    65 In []: x = linspace(0, 2*pi, 3)
       
    66 In []: plot(x, sin(x))
       
    67 \end{lstlisting}
       
    68 \end{frame}
       
    69 
       
    70 %% \begin{frame}[fragile]
       
    71 %% \frametitle{\incqno }
       
    72 %% Describe the plot produced by the following:
       
    73 %% \begin{lstlisting}
       
    74 %% In []: x = linspace(0, 2*pi, 50)
       
    75 %% In []: plot(x, cos(x), 'go')
       
    76 %% \end{lstlisting}
       
    77 %% \end{frame}
       
    78 
       
    79 \begin{frame}
       
    80 \frametitle{\incqno }
       
    81 How will you plot the previous graph with line width set to 3?  How will
       
    82 you set the $x$ and $y$ labels of the plot?
       
    83 \end{frame}
       
    84 
       
    85 \begin{frame}
       
    86 \frametitle{\incqno }
       
    87 How will you set the x and y axis limits so that the region of interest
       
    88 is in the rectangle $(0, -1.5)$ (left bottom coordinate) and $(2\pi,
       
    89 1.5)$ (right top coordinate)?
       
    90 \end{frame}
       
    91 
       
    92 \begin{frame}
       
    93 \frametitle{\incqno }
       
    94 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?
       
    95 \end{frame}
       
    96 
       
    97 \begin{frame}[fragile]
       
    98 \frametitle{\incqno }
       
    99 The following code snippet has an error/bug:
       
   100 \begin{lstlisting}
       
   101 In []: y = linspace(0, 2*pi, 50)
       
   102 In []: plot(y, sin(y))
       
   103 In []: clf()
       
   104 In []: plot(y, cos(y))
       
   105 In []: legend(['sin(y)', 'cos(y)']) 
       
   106 \end{lstlisting}
       
   107 What is the error? How do you fix it?  
       
   108 \end{frame}
       
   109 
       
   110 \begin{frame}[fragile]
       
   111 \frametitle{\incqno }
       
   112   \begin{lstlisting}
       
   113   In []: a = [1, 2, 5, 9]
       
   114   In []: a[0:-1]
       
   115   \end{lstlisting}
       
   116   What is the output?
       
   117 \end{frame}
       
   118 
       
   119 \begin{frame}
       
   120 \frametitle{\incqno }
       
   121   How do you combine two lists \emph{a} and \emph{b} to produce one list?
       
   122 \end{frame}
       
   123 
       
   124 \begin{frame}[fragile]
       
   125 \frametitle{\incqno }
       
   126   \begin{lstlisting}
       
   127   In []: a = [1, 2, 5, 9]
       
   128   \end{lstlisting}
       
   129   How do you add the value 10 to the end of this list?
       
   130 \end{frame}
       
   131 
       
   132 \begin{frame}
       
   133 \frametitle{\incqno }
       
   134 Write the code to read a file \texttt{data.txt} and print each line of it?
       
   135 \end{frame}
       
   136 
       
   137 \begin{frame}[fragile]
       
   138 \frametitle{\incqno }
       
   139 What would be the result of the following code snippet:
       
   140 \begin{lstlisting}
       
   141 In []: x = linspace(0, 10, 50)
       
   142 In []: y = linspace(50, 100, 100)
       
   143 In []: plot(x, y)
       
   144 \end{lstlisting}
       
   145 \end{frame}
       
   146 
       
   147 \begin{frame}[fragile]
       
   148 \frametitle{\incqno }
       
   149 The following code snippet has an error/bug:
       
   150 \begin{lstlisting}
       
   151 In []: l = [0.1, 0.2, 0.3, 0.4]
       
   152 In []: t = [0.69, 0.90, 1.19, 1.30]
       
   153 In []: tsq = []
       
   154 In []: for time in t:
       
   155  ....:     tsq.append(time*time)
       
   156  ....:     plot(l, tsq)
       
   157 \end{lstlisting}
       
   158 What is the error? How do you fix it?
       
   159 \end{frame}
       
   160 
       
   161 \begin{frame}
       
   162 \frametitle{\incqno }
       
   163   A sample line from a Comma Separated Values (CSV) file:\\
       
   164   \vspace*{0.2in}
       
   165   \emph{Rossum, Guido, 42, 56, 34, 54}\\
       
   166   \vspace*{0.2in}
       
   167   What code would you use to separate the line into fields?
       
   168 \end{frame}
       
   169 
       
   170 \begin{frame}[fragile]
       
   171 \frametitle{\incqno }
       
   172   \begin{lstlisting}
       
   173   In []: a = [1, 2, 5, 9]
       
   174   \end{lstlisting}
       
   175   How do you find the length of this list?
       
   176 \end{frame}
       
   177 
       
   178 \begin{frame}[fragile]
       
   179 \frametitle{\incqno }
       
   180   \begin{lstlisting}
       
   181   In [1]: d = {
       
   182           'a': 1,
       
   183           'b': 2
       
   184           }
       
   185   In [2]: print d['c']
       
   186   \end{lstlisting}
       
   187   What is the output?
       
   188 \end{frame}
       
   189 
       
   190 \begin{frame}[fragile]
       
   191 \frametitle{\incqno }
       
   192 \begin{lstlisting}
       
   193 In []: sc = {'A': 10, 'B': 20, 
       
   194              'C': 70}
       
   195 \end{lstlisting}
       
   196 Given the above dictionary, what command will you give to plot a
       
   197 pie-chart?
       
   198 \end{frame}
       
   199 
       
   200 \begin{frame}[fragile]
       
   201 \frametitle{\incqno }
       
   202 \begin{lstlisting}
       
   203 In []: marks = [10, 20, 30, 50, 55, 
       
   204                 75, 83] 
       
   205 \end{lstlisting}
       
   206 Given the above marks, how will you calculate the \alert{mean} and
       
   207 \alert{standard deviation}?
       
   208 \end{frame}
       
   209 
       
   210 \begin{frame}[fragile]
       
   211 \frametitle{\incqno }
       
   212 \begin{lstlisting}
       
   213 In []: marks = [10, 20, 30, 50, 55, 
       
   214                75, 83] 
       
   215 \end{lstlisting}
       
   216 How will you convert the list \texttt{marks} to an \alert{array}?
       
   217 \end{frame}
       
   218 
    61 \end{document}
   219 \end{document}