day2quiz.tex
changeset 344 19754ed6050f
parent 334 2214b5dba4d4
equal deleted inserted replaced
343:adb85e126341 344:19754ed6050f
    58     \item University/College/Company:
    58     \item University/College/Company:
    59     \item Student/Teacher/Professional:
    59     \item Student/Teacher/Professional:
    60   \end{itemize}
    60   \end{itemize}
    61 \end{frame}
    61 \end{frame}
    62 
    62 
    63 
       
    64 \begin{frame}
       
    65 \frametitle{\incqno }
       
    66   What is the largest integer value that can be represented natively by Python?
       
    67 \end{frame}
       
    68 
       
    69 \begin{frame}
       
    70 \frametitle{\incqno }
       
    71   What is the result of 17.0 / 2?
       
    72 \end{frame}
       
    73 
       
    74 \begin{frame}
       
    75 \frametitle{\incqno }
       
    76   Which of the following is not a type in Python?
       
    77   \begin{enumerate}
       
    78     \item int
       
    79     \item float
       
    80     \item char
       
    81     \item string
       
    82   \end{enumerate}
       
    83 \end{frame}
       
    84 
       
    85 \begin{frame}
       
    86 \frametitle{\incqno }
       
    87 How do you create a complex number with real part 2 and imaginary part
       
    88 0.5.
       
    89 \end{frame}
       
    90 
       
    91 \begin{frame}
       
    92 \frametitle{\incqno }
       
    93   What is the difference between \kwrd{print} \emph{x} and \kwrd{print} \emph{x,} ?
       
    94 \end{frame}
       
    95 
       
    96 \begin{frame}
       
    97 \frametitle{\incqno }
       
    98   What does '*' * 40 produce?
       
    99 \end{frame}
       
   100 
       
   101 \begin{frame}[fragile]
       
   102 \frametitle{\incqno }
       
   103     What is the output of:
       
   104     \begin{lstlisting}
       
   105 In []: ', '.join(['a', 'b', 'c'])
       
   106     \end{lstlisting}
       
   107 \end{frame}
       
   108 
       
   109 \begin{frame}
       
   110     \frametitle{\incqno}
       
   111   How do you find the presence of an element \emph{x} in the list \emph{a}?
       
   112 \end{frame}
       
   113 
       
   114 \begin{frame}[fragile]
       
   115     \frametitle{\incqno}
       
   116   \begin{lstlisting}
       
   117 In []: set([1, 2, 8, 2, 13, 8, 9])
       
   118   \end{lstlisting}
       
   119   What is the output?
       
   120 \end{frame}
       
   121 
       
   122 \begin{frame}[fragile]
       
   123     \frametitle{\incqno}
       
   124   \begin{lstlisting}
       
   125 In []: 47 % 3 
       
   126   \end{lstlisting}
       
   127   What is the output?
       
   128 \end{frame}
       
   129 
       
   130 \begin{frame}[fragile]
       
   131     \frametitle{\incqno}
       
   132   \begin{lstlisting}
       
   133 In []: a = 12
       
   134 In []: a *= 1+1
       
   135   \end{lstlisting}
       
   136   What is the value of a?
       
   137 \end{frame}
       
   138 
       
   139 \begin{frame}[fragile]
       
   140     \frametitle{\incqno}
       
   141   \begin{lstlisting}
       
   142 In []: a = {'a': 1, 'b': 2} 
       
   143 In []: a['a'] = 10
       
   144 In []: print a
       
   145   \end{lstlisting}
       
   146   What is the output?
       
   147 \end{frame}
       
   148 
       
   149 \begin{frame}[fragile]
       
   150     \frametitle{\incqno}
       
   151   \begin{lstlisting}
       
   152 In []: for i in range(3, 10, 2):
       
   153   ...:     print i
       
   154   \end{lstlisting}
       
   155   What is the output?
       
   156 \end{frame}
       
   157 
       
   158 \begin{frame}[fragile]
       
   159     \frametitle{\incqno}
       
   160   \begin{lstlisting}
       
   161 In []: a = [1, 2, 3] 
       
   162 In []: a.extend([5, 6])
       
   163   \end{lstlisting}
       
   164   What is the value of a?
       
   165 \end{frame}
       
   166 
       
   167 \begin{frame}[fragile]
       
   168     \frametitle{\incqno}
       
   169   \begin{lstlisting}
       
   170 In []: a = (1, 2, 3)
       
   171 In []: a[1] = 10
       
   172   \end{lstlisting}
       
   173   What is the result?
       
   174 \end{frame}
       
   175 
       
   176 \begin{frame}[fragile]
       
   177     \frametitle{\incqno}
       
   178   \begin{lstlisting}
       
   179 def func(x, y=10):
       
   180     print x+1, y+10
       
   181 
       
   182 func(1)
       
   183 
       
   184   \end{lstlisting}
       
   185 
       
   186   What is the output?
       
   187 \end{frame}
       
   188 
       
   189 \begin{frame}
       
   190     \frametitle{\incqno}
       
   191   How many items can a function return?
       
   192 \end{frame}
       
   193 
       
   194 %% \begin{frame}[fragile]
       
   195 %%     \frametitle{\incqno}
       
   196 %%     Consider a module called \lstinline+gcd.py+ looking like this:
       
   197 %%     \begin{lstlisting}
       
   198 %% def gcd(a, b):
       
   199 %%    ...
       
   200 
       
   201 %% if __name__ == '__main__':
       
   202 %%     print gcd(10, 25)
       
   203 %%     \end{lstlisting}
       
   204 %% If this module is imported, will it print the gcd of 10 and 25?
       
   205 %% \end{frame}
       
   206 
       
   207 %% \begin{frame}[fragile]
       
   208 %%     \frametitle{\incqno}
       
   209 %%   \begin{lstlisting}
       
   210 %% In [1]: print hello 
       
   211 %%   \end{lstlisting}
       
   212 %%   Exactly what exception will you get if you run this on a fresh
       
   213 %%   interpreter?
       
   214 %% \end{frame}
       
   215 
       
   216 \end{document}
    63 \end{document}
   217 
    64