question_bank.xml
changeset 46 b45bb982ae24
parent 39 0fa055b8ea98
child 47 8a837762531b
equal deleted inserted replaced
45:3be60e26e14f 46:b45bb982ae24
     1 <questionbank>
     1 <questionbank>
     2 <day1quiz1>
     2 <day1quiz1>
     3 
     3 
     4 <question>
     4 <question>
     5 <description>
     5 <description>
     6 How will you set the x and y axis limits so that the region of interest is in the rectangle (0, -1.5) and (2\pi, 1.5)?
     6 Describe the plot produced by the following code
       
     7 </description>
       
     8 <time_limit>
       
     9 30
       
    10 </time_limit>
       
    11 <code>
       
    12 In []: x = linspace(0, 2*pi, 50)
       
    13 In []: plot(x, cos(x), 'go')
       
    14 </code>
       
    15 <expected_answer>
       
    16 Correct this question manually
       
    17 </expected_answer>
       
    18 </question>
       
    19 
       
    20 <question>
       
    21 <description>
       
    22 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?
       
    23 </description>
       
    24 <time_limit>
       
    25 30
       
    26 </time_limit>
       
    27 <expected_answer>
       
    28 \%hist \%save
       
    29 </expected_answer>
       
    30 </question>
       
    31 
       
    32 <question>
       
    33 <description>
       
    34 How do you set the x and y labels of a plot to "x" and "sin(x)" ?
       
    35 </description>
       
    36 <time_limit>
       
    37 60
       
    38 </time_limit>
       
    39 <expected_answer>
       
    40 xlabel \( \" x \" \) ylabel \( \"sin\(x\)\" \)
       
    41 xlabel \( \" x \" \) ylabel \( \'sin\(x\)\' \)
       
    42 xlabel \( \' x \' \) ylabel \( \"sin\(x\)\" \)
       
    43 xlabel \( \' x \' \) ylabel \( \'sin\(x\)\' \)
       
    44 </expected_answer>
       
    45 </question>
       
    46 
       
    47 <question>
       
    48 <description>
       
    49 How will you set the x and y axis limits so that the region of interest is in the rectangle (0, -1.5) and (2 pi, 1.5)?
     7 </description>
    50 </description>
     8 <time_limit>
    51 <time_limit>
     9 90
    52 90
    10 </time_limit>
    53 </time_limit>
    11 <expected_answer>
    54 <expected_answer>
    12 xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1.5 , 1.5\)
    55 xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1\.5 , 1\.5 \)
    13 </expected_answer>
    56 </expected_answer>
    14 </question>
    57 </question>
    15 
    58 
    16 <question>
    59 <question>
    17 <description>
    60 <description>
    18 If a = [1, 2, 5, 9] then what is the value of a[0:-1]
    61 How do you combine two lists a and b to produce one list?
    19 </description>
    62 </description>
    20 <time_limit>
    63 <time_limit>
    21 30
    64 30
    22 </time_limit>
    65 </time_limit>
    23 <expected_answer>
    66 <expected_answer>
    24 \[ 1 , 2 , 5 \]
    67 a \+ b
    25 </expected_answer>
    68 </expected_answer>
    26 </question>
    69 </question>
    27 
    70 
    28 <question>
    71 <question>
    29 <description>
    72 <description>
    30 A sample line from a Comma Separated Values (CSV) file:
    73 If a = [1, 2, 5, 9] how do you add 10 to the end of this list ?
    31 line = "Rossum, Guido, 42, 56, 34, 54"
    74 </description>
       
    75 <time_limit>
       
    76 30
       
    77 </time_limit>
       
    78 <expected_answer>
       
    79 a\.append \( 10 \)
       
    80 a = a \+ \[ 10 \]
       
    81 a \+= \[ 10 \]
       
    82 </expected_answer>
       
    83 </question>
       
    84 
       
    85 <question>
       
    86 <description>
       
    87 Write the code to read a file "data.txt" and print each line of it?
       
    88 </description>
       
    89 <time_limit>
       
    90 60
       
    91 </time_limit>
       
    92 <expected_answer>
       
    93 correct this manually
       
    94 </expected_answer>
       
    95 </question>
       
    96 
       
    97 <question>
       
    98 <description>
       
    99 The following code snippet has an error/bug.
       
   100 What is the error?
       
   101 </description>
       
   102 <code>
       
   103 In []: l = [0.1, 0.2, 0.3, 0.4]
       
   104 In []: t = [0.69, 0.90, 1.19, 1.30]
       
   105 In []: tsq = []
       
   106 In []: for time in t:
       
   107  ....:     tsq.append(time*time)
       
   108  ....:     plot(l, tsq)
       
   109 </code>
       
   110 <time_limit>
       
   111 60
       
   112 </time_limit>
       
   113 <expected_answer>
       
   114 plot
       
   115 </expected_answer>
       
   116 </question>
       
   117 
       
   118 <question>
       
   119 <description>
       
   120 "Rossum, Guido, 42, 56, 34, 54" is a sample line from a Comma Separated Values (CSV) file
    32 What code would you use to separate the line into fields?
   121 What code would you use to separate the line into fields?
    33 </description>
   122 </description>
    34 <time_limit>
   123 <time_limit>
    35 30
   124 30
    36 </time_limit>
   125 </time_limit>
    37 <expected_answer>
   126 <expected_answer>
    38 line\.split \( \" , \" \)
   127 \.split \( " , " \)
    39 line\.split \( \' , \' \)
   128 \.split \( ' , ' \)
    40 </expected_answer>
   129 </expected_answer>
    41 </question>
   130 </question>
    42 
   131 
    43 <question>
   132 <question>
    44 <description>
   133 <description>
    47 <time_limit>
   136 <time_limit>
    48 30
   137 30
    49 </time_limit>
   138 </time_limit>
    50 <expected_answer>
   139 <expected_answer>
    51 len \( a \)
   140 len \( a \)
       
   141 </expected_answer>
       
   142 </question>
       
   143 
       
   144 <question>
       
   145 <description>
       
   146 What is the output of the following code snippet
       
   147 </description>
       
   148 <code>
       
   149 In [1]: d = {
       
   150 	  'a': 1,
       
   151 	  'b': 2
       
   152 	  }
       
   153 In [2]: print d['c']
       
   154 </code>
       
   155 <time_limit>
       
   156 30
       
   157 </time_limit>
       
   158 <expected_answer>
       
   159 error
       
   160 Error
       
   161 ERROR
       
   162 </expected_answer>
       
   163 </question>
       
   164 
       
   165 <question>
       
   166 <description>
       
   167 Given the below dictionary, what command will you give to plot a pie-chart?
       
   168 </description>
       
   169 <code>
       
   170 In []: sc = {'A': 10, 'B': 20, 
       
   171              'C': 70}
       
   172 </code>
       
   173 <time_limit>
       
   174 60
       
   175 </time_limit>
       
   176 <expected_answer>
       
   177 pie \( sc\.values \( \) \)
       
   178 pie \( sc\.values \( \) , labels = sc\.keys \( \) \)
       
   179 </expected_answer>
       
   180 </question>
       
   181 
       
   182 <question>
       
   183 <description>
       
   184 Given the below marks, how will you calculate the mean?
       
   185 </description>
       
   186 <code>
       
   187 In []: marks = [10, 20, 30, 50, 55, 
       
   188                 75, 83] 
       
   189 </code>
       
   190 <time_limit>
       
   191 30
       
   192 </time_limit>
       
   193 <expected_answer>
       
   194 mean \( marks \)
       
   195 sum \( marks \) \/ len \( marks \)
       
   196 </expected_answer>
       
   197 </question>
       
   198 
       
   199 <question>
       
   200 <description>
       
   201 How will you convert the list marks to an array?
       
   202 </description>
       
   203 <code>
       
   204 In []: marks = [10, 20, 30, 50, 55, 75, 83]
       
   205 </code>
       
   206 <time_limit>
       
   207 30
       
   208 </time_limit>
       
   209 <expected_answer>
       
   210 array \( marks \)
    52 </expected_answer>
   211 </expected_answer>
    53 </question>
   212 </question>
    54 
   213 
    55 </day1quiz1>
   214 </day1quiz1>
    56 
   215