question_bank.xml
changeset 47 8a837762531b
parent 46 b45bb982ae24
child 49 3643f59f141e
equal deleted inserted replaced
46:b45bb982ae24 47:8a837762531b
   144 <question>
   144 <question>
   145 <description>
   145 <description>
   146 What is the output of the following code snippet
   146 What is the output of the following code snippet
   147 </description>
   147 </description>
   148 <code>
   148 <code>
   149 In [1]: d = {
   149 In [1]: d = {'a': 1,
   150 	  'a': 1,
   150              'b': 2
   151 	  'b': 2
   151             }
   152 	  }
       
   153 In [2]: print d['c']
   152 In [2]: print d['c']
   154 </code>
   153 </code>
   155 <time_limit>
   154 <time_limit>
   156 30
   155 30
   157 </time_limit>
   156 </time_limit>
   165 <question>
   164 <question>
   166 <description>
   165 <description>
   167 Given the below dictionary, what command will you give to plot a pie-chart?
   166 Given the below dictionary, what command will you give to plot a pie-chart?
   168 </description>
   167 </description>
   169 <code>
   168 <code>
   170 In []: sc = {'A': 10, 'B': 20, 
   169 In []: sc = {'A': 10, 'B': 20, 'C': 70}
   171              'C': 70}
       
   172 </code>
   170 </code>
   173 <time_limit>
   171 <time_limit>
   174 60
   172 60
   175 </time_limit>
   173 </time_limit>
   176 <expected_answer>
   174 <expected_answer>
   182 <question>
   180 <question>
   183 <description>
   181 <description>
   184 Given the below marks, how will you calculate the mean?
   182 Given the below marks, how will you calculate the mean?
   185 </description>
   183 </description>
   186 <code>
   184 <code>
   187 In []: marks = [10, 20, 30, 50, 55, 
   185 In []: marks = [10, 20, 30, 50, 55, 75, 83] 
   188                 75, 83] 
       
   189 </code>
   186 </code>
   190 <time_limit>
   187 <time_limit>
   191 30
   188 30
   192 </time_limit>
   189 </time_limit>
   193 <expected_answer>
   190 <expected_answer>
   212 </question>
   209 </question>
   213 
   210 
   214 </day1quiz1>
   211 </day1quiz1>
   215 
   212 
   216 <day1quiz2>
   213 <day1quiz2>
       
   214 
       
   215 <question>
       
   216 <description>
       
   217 What is the value of a after executing this code.
       
   218 </description>
       
   219 <code>
       
   220 In []: a = array([[1, 2],
       
   221                   [3, 4]])
       
   222 In []: a[1,0] = 0
       
   223 </code>
       
   224 <time_limit>
       
   225 60
       
   226 </time_limit>
       
   227 <expected_answer>
       
   228 \[ \[ 1 , 2 \] , \[ 0 , 4 \] \]
       
   229 </expected_answer>
       
   230 </question>
       
   231 
       
   232 <question>
       
   233 <description>
       
   234 What will be printed?
       
   235 </description>
       
   236 <code>
       
   237 In []: x = array(([1,2,3,4],
       
   238                   [2,3,4,5]))
       
   239 In []: x[-2][-3] = 4
       
   240 In []: print x
       
   241 </code>
       
   242 <time_limit>
       
   243 90
       
   244 </time_limit>
       
   245 <expected_answer>
       
   246 array \( \( \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \) \)
       
   247 array \( \[ \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \] \)
       
   248 \[ \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \]
       
   249 \( \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \)
       
   250 </expected_answer>
       
   251 </question>
       
   252 
       
   253 <question>
       
   254 <description>
       
   255 If x = array([[1,2,3,4]]) How to change x to array([[1,2,0,4]]) ?
       
   256 </description>
       
   257 <time_limit>
       
   258 60
       
   259 </time_limit>
       
   260 <expected_answer>
       
   261 x\[ 0 \]\[ 2 \] = 0
       
   262 </expected_answer>
       
   263 </question>
       
   264 
       
   265 <question>
       
   266 <description>
       
   267 
       
   268 x = array([[1,2,3,4],
       
   269            [3,4,2,5]])
       
   270 		 
       
   271 How do you get the following slice of x ?
       
   272 
       
   273 array([[2,3],
       
   274       [4,2]])
       
   275        
       
   276 </description>
       
   277 <time_limit>
       
   278 60
       
   279 </time_limit>
       
   280 <expected_answer>
       
   281 x\[ \: , 1 \: 3 \]
       
   282 x\[ \: , 1 \: -1 \]
       
   283 x\[ \: , -3 \: -1 \]
       
   284 </expected_answer>
       
   285 </question>
       
   286 
       
   287 <question>
       
   288 <description>
       
   289 What is the output of x[::3,::3]
       
   290 </description>
       
   291 <code>
       
   292 In []: x = array([[9,18,27],
       
   293                   [30,60,90],
       
   294                   [14,7,1]])
       
   295 </code>
       
   296 <time_limit>
       
   297 30
       
   298 </time_limit>
       
   299 <expected_answer>
       
   300 9
       
   301 </expected_answer>
       
   302 </question>
       
   303 
       
   304 <question>
       
   305 <description>
       
   306 How do you get the transpose of this array?
       
   307 </description>
       
   308 <code>
       
   309 In []: a = array([[1, 2],
       
   310                   [3, 4]])
       
   311 </code>
       
   312 <time_limit>
       
   313 30
       
   314 </time_limit>
       
   315 <expected_answer>
       
   316 a\.T
       
   317 </expected_answer>
       
   318 </question>
       
   319 
       
   320 <question>
       
   321 <description>
       
   322 What does this produce?
       
   323 </description>
       
   324 <code>
       
   325 In []: a = array([[1, 2],
       
   326                   [3, 4]])
       
   327 In []: b = array([[1, 1],
       
   328                   [2, 2]])
       
   329 In []: a*b
       
   330 </code>
       
   331 <time_limit>
       
   332 45
       
   333 </time_limit>
       
   334 <expected_answer>
       
   335 array \( \[ \[ 1 , 2 \] , \[ 6 , 8 \] \] \)
       
   336 \[ \[ 1 , 2 \] , \[ 6 , 8 \] \]
       
   337 </expected_answer>
       
   338 </question>
       
   339 
       
   340 <question>
       
   341 <description>
       
   342 What command do you use to find the inverse of a matrix and its eigenvalues?
       
   343 </description>
       
   344 <time_limit>
       
   345 30
       
   346 </time_limit>
       
   347 <expected_answer>
       
   348 inv .* eigvals
       
   349 </expected_answer>
       
   350 </question>
       
   351 
       
   352 <question>
       
   353 <description>
       
   354 Given a 4x4 matrix A and a 4-vector b , what command do you use to solve for the equation Ax = b ?
       
   355 </description>
       
   356 <time_limit>
       
   357 45
       
   358 </time_limit>
       
   359 <expected_answer>
       
   360 solve \( A , b \)
       
   361 </expected_answer>
       
   362 </question>
       
   363 
       
   364 <question>
       
   365 <description>
       
   366 How do you calculate the roots of the polynomial, y = 1 + 6*x + 8*x^2 + x^3 
       
   367 </description>
       
   368 <time_limit>
       
   369 45
       
   370 </time_limit>
       
   371 <expected_answer>
       
   372 roots \( \[ 1 , 8 , 6 , 1 \] \)
       
   373 </expected_answer>
       
   374 </question>
       
   375 
       
   376 <question>
       
   377 <description>
       
   378 Two arrays a and b are numerically almost equal, what command do you use to check if this is true?
       
   379 </description>
       
   380 <time_limit>
       
   381 30
       
   382 </time_limit>
       
   383 <expected_answer>
       
   384 allclose \( a , b \)
       
   385 allclose \( b , a \)
       
   386 </expected_answer>
       
   387 </question>
       
   388 
   217 </day1quiz2>
   389 </day1quiz2>
   218 
   390 
   219 </questionbank>
   391 </questionbank>