day2quiz.tex
changeset 306 57291186d598
child 334 2214b5dba4d4
equal deleted inserted replaced
305:43bfb88594c0 306:57291186d598
       
     1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
     2 % Quiz slides day 1 quiz 1
       
     3 %
       
     4 % Author: FOSSEE <info at fossee  dot in>
       
     5 % Copyright (c) 2005-2009, FOSSEE Team
       
     6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
     7 
       
     8 
       
     9 \documentclass[14pt,compress]{beamer}
       
    10 
       
    11 \mode<presentation>
       
    12 {
       
    13   \useoutertheme{split}
       
    14   \setbeamercovered{transparent}
       
    15 }
       
    16 
       
    17 \definecolor{darkgreen}{rgb}{0,0.5,0}
       
    18 
       
    19 \usepackage{listings}
       
    20 \lstset{language=Python,
       
    21     basicstyle=\ttfamily\bfseries,
       
    22     commentstyle=\color{red}\itshape,
       
    23   stringstyle=\color{darkgreen},
       
    24   showstringspaces=false,
       
    25   keywordstyle=\color{blue}\bfseries}
       
    26 
       
    27 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
       
    28 
       
    29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    30 % Macros
       
    31 
       
    32 \newcounter{qno}
       
    33 \setcounter{qno}{0}
       
    34 \newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}}
       
    35 
       
    36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    37 % Title page
       
    38 \title[Basic Python]{Python for science and engineering: Day 2, Quiz 1}
       
    39 
       
    40 \author[FOSSEE Team] {FOSSEE}
       
    41 
       
    42 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
       
    43 \date[] {\today \\ Day 2, Quiz 1}
       
    44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    45 
       
    46 
       
    47 \begin{document}
       
    48 
       
    49 \begin{frame}
       
    50   \titlepage
       
    51 \end{frame}
       
    52 
       
    53 \begin{frame}
       
    54   \frametitle{Write your details...}
       
    55 On the top right hand corner please write down the following:
       
    56   \begin{itemize}
       
    57     \item Name:
       
    58     \item University/College/Company:
       
    59     \item Student/Teacher/Professional:
       
    60   \end{itemize}
       
    61 \end{frame}
       
    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}[fragile]
       
    92 \frametitle{\incqno }
       
    93   What happens when we run this code?
       
    94   \begin{lstlisting}
       
    95 a = False
       
    96 b = True
       
    97 c = True
       
    98 if a and b or c:
       
    99     print "You are correct!"
       
   100   \end{lstlisting}
       
   101 \end{frame}
       
   102 
       
   103 \begin{frame}
       
   104 \frametitle{\incqno }
       
   105   What is the difference between \kwrd{print} \emph{x} and \kwrd{print} \emph{x,} ?
       
   106 \end{frame}
       
   107 
       
   108 \begin{frame}
       
   109 \frametitle{\incqno }
       
   110   What does '*' * 40 produce?
       
   111 \end{frame}
       
   112 
       
   113 \begin{frame}[fragile]
       
   114 \frametitle{\incqno }
       
   115     What is the output of:
       
   116     \begin{lstlisting}
       
   117 In []: ', '.join(['a', 'b', 'c'])
       
   118     \end{lstlisting}
       
   119 \end{frame}
       
   120 
       
   121 \begin{frame}
       
   122     \frametitle{\incqno}
       
   123   How do you find the presence of an element \emph{x} in the list \emph{a}?
       
   124 \end{frame}
       
   125 
       
   126 \begin{frame}[fragile]
       
   127     \frametitle{\incqno}
       
   128   \begin{lstlisting}
       
   129 In []: set([1, 2, 8, 2, 13, 8, 9])
       
   130   \end{lstlisting}
       
   131   What is the output?
       
   132 \end{frame}
       
   133 
       
   134 \begin{frame}[fragile]
       
   135     \frametitle{\incqno}
       
   136   \begin{lstlisting}
       
   137 In []: 47%3 
       
   138   \end{lstlisting}
       
   139   What is the output?
       
   140 \end{frame}
       
   141 
       
   142 \begin{frame}[fragile]
       
   143     \frametitle{\incqno}
       
   144   \begin{lstlisting}
       
   145 In []: a = 12
       
   146 In []: a *= 1+1
       
   147   \end{lstlisting}
       
   148   What is the value of a?
       
   149 \end{frame}
       
   150 
       
   151 \begin{frame}[fragile]
       
   152     \frametitle{\incqno}
       
   153   \begin{lstlisting}
       
   154 In []: a = {'a': 1, 'b': 2} 
       
   155 In []: a['a'] = 10
       
   156 In []: print a
       
   157   \end{lstlisting}
       
   158   What is the output?
       
   159 \end{frame}
       
   160 
       
   161 \begin{frame}[fragile]
       
   162     \frametitle{\incqno}
       
   163   \begin{lstlisting}
       
   164 In []: for i in range(3, 10, 2):
       
   165   ...:     print i
       
   166   \end{lstlisting}
       
   167   What is the output?
       
   168 \end{frame}
       
   169 
       
   170 \begin{frame}[fragile]
       
   171     \frametitle{\incqno}
       
   172   \begin{lstlisting}
       
   173 In []: a = [1, 2, 3] 
       
   174 In []: a.extend([5, 6])
       
   175   \end{lstlisting}
       
   176   What is the value of a?
       
   177 \end{frame}
       
   178 
       
   179 \begin{frame}[fragile]
       
   180     \frametitle{\incqno}
       
   181   \begin{lstlisting}
       
   182 In []: a = (1, 2, 3)
       
   183 In []: a[1] = 10
       
   184   \end{lstlisting}
       
   185   What is the result?
       
   186 \end{frame}
       
   187 
       
   188 \begin{frame}[fragile]
       
   189     \frametitle{\incqno}
       
   190   \begin{lstlisting}
       
   191 def func(x, y=10):
       
   192     print x+1, y+10
       
   193 
       
   194 func(1)
       
   195 
       
   196   \end{lstlisting}
       
   197 
       
   198   What is the output?
       
   199 \end{frame}
       
   200 
       
   201 \begin{frame}
       
   202     \frametitle{\incqno}
       
   203   How many items can a function return?
       
   204 \end{frame}
       
   205 
       
   206 %% \begin{frame}[fragile]
       
   207 %%     \frametitle{\incqno}
       
   208 %%     Consider a module called \lstinline+gcd.py+ looking like this:
       
   209 %%     \begin{lstlisting}
       
   210 %% def gcd(a, b):
       
   211 %%    ...
       
   212 
       
   213 %% if __name__ == '__main__':
       
   214 %%     print gcd(10, 25)
       
   215 %%     \end{lstlisting}
       
   216 %% If this module is imported, will it print the gcd of 10 and 25?
       
   217 %% \end{frame}
       
   218 
       
   219 %% \begin{frame}[fragile]
       
   220 %%     \frametitle{\incqno}
       
   221 %%   \begin{lstlisting}
       
   222 %% In [1]: print hello 
       
   223 %%   \end{lstlisting}
       
   224 %%   Exactly what exception will you get if you run this on a fresh
       
   225 %%   interpreter?
       
   226 %% \end{frame}
       
   227 
       
   228 \end{document}
       
   229