question_bank.xml
changeset 59 0b57494e8b4e
parent 58 672409e18e16
child 89 f8e25dea5222
equal deleted inserted replaced
58:672409e18e16 59:0b57494e8b4e
     1 <questionbank>
     1 <questionbank>
     2 
     2 
     3 <question>
     3 <question>
       
     4 <topic>Plotting</topic>
     4 <description>
     5 <description>
     5 Describe the plot produced by the following code
     6 Describe the plot produced by the following code
     6 </description>
     7 </description>
     7 <time_limit>
     8 <time_limit>
     8 30
     9 30
    15 Correct this question manually
    16 Correct this question manually
    16 </expected_answer>
    17 </expected_answer>
    17 </question>
    18 </question>
    18 
    19 
    19 <question>
    20 <question>
       
    21 <topic>Plotting</topic>
    20 <description>
    22 <description>
    21 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 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?
    22 </description>
    24 </description>
    23 <time_limit>
    25 <time_limit>
    24 30
    26 30
    27 \%hist \%save
    29 \%hist \%save
    28 </expected_answer>
    30 </expected_answer>
    29 </question>
    31 </question>
    30 
    32 
    31 <question>
    33 <question>
       
    34 <topic>Plotting</topic>
    32 <description>
    35 <description>
    33 How do you set the x and y labels of a plot to "x" and "sin(x)" ?
    36 How do you set the x and y labels of a plot to "x" and "sin(x)" ?
    34 </description>
    37 </description>
    35 <time_limit>
    38 <time_limit>
    36 60
    39 60
    42 xlabel \( \' x \' \) ylabel \( \'sin\(x\)\' \)
    45 xlabel \( \' x \' \) ylabel \( \'sin\(x\)\' \)
    43 </expected_answer>
    46 </expected_answer>
    44 </question>
    47 </question>
    45 
    48 
    46 <question>
    49 <question>
       
    50 <topic>Plotting</topic>
    47 <description>
    51 <description>
    48 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)?
    52 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)?
    49 </description>
    53 </description>
    50 <time_limit>
    54 <time_limit>
    51 90
    55 90
    54 xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1\.5 , 1\.5 \)
    58 xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1\.5 , 1\.5 \)
    55 </expected_answer>
    59 </expected_answer>
    56 </question>
    60 </question>
    57 
    61 
    58 <question>
    62 <question>
       
    63 <topic>Lists and Files</topic>
    59 <description>
    64 <description>
    60 How do you combine two lists a and b to produce one list?
    65 How do you combine two lists a and b to produce one list?
    61 </description>
    66 </description>
    62 <time_limit>
    67 <time_limit>
    63 30
    68 30
    66 a \+ b
    71 a \+ b
    67 </expected_answer>
    72 </expected_answer>
    68 </question>
    73 </question>
    69 
    74 
    70 <question>
    75 <question>
       
    76 <topic>Lists and Files</topic>
    71 <description>
    77 <description>
    72 If a = [1, 2, 5, 9] how do you add 10 to the end of this list ?
    78 If a = [1, 2, 5, 9] how do you add 10 to the end of this list ?
    73 </description>
    79 </description>
    74 <time_limit>
    80 <time_limit>
    75 30
    81 30
    80 a \+= \[ 10 \]
    86 a \+= \[ 10 \]
    81 </expected_answer>
    87 </expected_answer>
    82 </question>
    88 </question>
    83 
    89 
    84 <question>
    90 <question>
       
    91 <topic>Lists and Files</topic>
    85 <description>
    92 <description>
    86 Write the code to read a file "data.txt" and print each line of it?
    93 Write the code to read a file "data.txt" and print each line of it?
    87 </description>
    94 </description>
    88 <time_limit>
    95 <time_limit>
    89 60
    96 60
    92 correct this manually
    99 correct this manually
    93 </expected_answer>
   100 </expected_answer>
    94 </question>
   101 </question>
    95 
   102 
    96 <question>
   103 <question>
       
   104 <topic>For Loops</topic>
    97 <description>
   105 <description>
    98 The following code snippet has an error/bug.
   106 The following code snippet has an error/bug.
    99 What is the error?
   107 What is the error?
   100 </description>
   108 </description>
   101 <code>
   109 <code>
   113 plot
   121 plot
   114 </expected_answer>
   122 </expected_answer>
   115 </question>
   123 </question>
   116 
   124 
   117 <question>
   125 <question>
       
   126 <topic>Strings</topic>
   118 <description>
   127 <description>
   119 "Rossum, Guido, 42, 56, 34, 54" is a sample line from a Comma Separated Values (CSV) file
   128 "Rossum, Guido, 42, 56, 34, 54" is a sample line from a Comma Separated Values (CSV) file
   120 What code would you use to separate the line into fields?
   129 What code would you use to separate the line into fields?
   121 </description>
   130 </description>
   122 <time_limit>
   131 <time_limit>
   127 \.split \( ' , ' \)
   136 \.split \( ' , ' \)
   128 </expected_answer>
   137 </expected_answer>
   129 </question>
   138 </question>
   130 
   139 
   131 <question>
   140 <question>
       
   141 <topic>Lists and Files</topic>
   132 <description>
   142 <description>
   133 If a = [1, 2, 5, 9] how do you find the length of this list?
   143 If a = [1, 2, 5, 9] how do you find the length of this list?
   134 </description>
   144 </description>
   135 <time_limit>
   145 <time_limit>
   136 30
   146 30
   139 len \( a \)
   149 len \( a \)
   140 </expected_answer>
   150 </expected_answer>
   141 </question>
   151 </question>
   142 
   152 
   143 <question>
   153 <question>
       
   154 <topic>Dictionaries and Piecharts</topic>
   144 <description>
   155 <description>
   145 What is the output of the following code snippet
   156 What is the output of the following code snippet
   146 </description>
   157 </description>
   147 <code>
   158 <code>
   148 In [1]: d = {'a': 1,
   159 In [1]: d = {'a': 1,
   159 ERROR
   170 ERROR
   160 </expected_answer>
   171 </expected_answer>
   161 </question>
   172 </question>
   162 
   173 
   163 <question>
   174 <question>
       
   175 <topic>Dictionaries and Piecharts</topic>
   164 <description>
   176 <description>
   165 Given the below dictionary, what command will you give to plot a pie-chart?
   177 Given the below dictionary, what command will you give to plot a pie-chart?
   166 </description>
   178 </description>
   167 <code>
   179 <code>
   168 In []: sc = {'A': 10, 'B': 20, 'C': 70}
   180 In []: sc = {'A': 10, 'B': 20, 'C': 70}
   175 pie \( sc\.values \( \) , labels = sc\.keys \( \) \)
   187 pie \( sc\.values \( \) , labels = sc\.keys \( \) \)
   176 </expected_answer>
   188 </expected_answer>
   177 </question>
   189 </question>
   178 
   190 
   179 <question>
   191 <question>
       
   192 <topic>Statistics</topic>
   180 <description>
   193 <description>
   181 Given the below marks, how will you calculate the mean?
   194 Given the below marks, how will you calculate the mean?
   182 </description>
   195 </description>
   183 <code>
   196 <code>
   184 In []: marks = [10, 20, 30, 50, 55, 75, 83] 
   197 In []: marks = [10, 20, 30, 50, 55, 75, 83] 
   191 sum \( marks \) \/ len \( marks \)
   204 sum \( marks \) \/ len \( marks \)
   192 </expected_answer>
   205 </expected_answer>
   193 </question>
   206 </question>
   194 
   207 
   195 <question>
   208 <question>
       
   209 <topic>Arrays and Matrices</topic>
   196 <description>
   210 <description>
   197 How will you convert the list marks to an array?
   211 How will you convert the list marks to an array?
   198 </description>
   212 </description>
   199 <code>
   213 <code>
   200 In []: marks = [10, 20, 30, 50, 55, 75, 83]
   214 In []: marks = [10, 20, 30, 50, 55, 75, 83]
   206 array \( marks \)
   220 array \( marks \)
   207 </expected_answer>
   221 </expected_answer>
   208 </question>
   222 </question>
   209 
   223 
   210 <question>
   224 <question>
       
   225 <topic>Arrays and Matrices</topic>
   211 <description>
   226 <description>
   212 What is the value of a after executing this code.
   227 What is the value of a after executing this code.
   213 </description>
   228 </description>
   214 <code>
   229 <code>
   215 In []: a = array([[1, 2],
   230 In []: a = array([[1, 2],
   223 \[ \[ 1 , 2 \] , \[ 0 , 4 \] \]
   238 \[ \[ 1 , 2 \] , \[ 0 , 4 \] \]
   224 </expected_answer>
   239 </expected_answer>
   225 </question>
   240 </question>
   226 
   241 
   227 <question>
   242 <question>
       
   243 <topic>Arrays and Matrices</topic>
   228 <description>
   244 <description>
   229 What will be printed?
   245 What will be printed?
   230 </description>
   246 </description>
   231 <code>
   247 <code>
   232 In []: x = array(([1,2,3,4],
   248 In []: x = array(([1,2,3,4],
   244 \( \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \)
   260 \( \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \)
   245 </expected_answer>
   261 </expected_answer>
   246 </question>
   262 </question>
   247 
   263 
   248 <question>
   264 <question>
       
   265 <topic>Arrays and Matrices</topic>
   249 <description>
   266 <description>
   250 If x = array([[1,2,3,4]]) How to change x to array([[1,2,0,4]]) ?
   267 If x = array([[1,2,3,4]]) How to change x to array([[1,2,0,4]]) ?
   251 </description>
   268 </description>
   252 <time_limit>
   269 <time_limit>
   253 60
   270 60
   256 x\[ 0 \]\[ 2 \] = 0
   273 x\[ 0 \]\[ 2 \] = 0
   257 </expected_answer>
   274 </expected_answer>
   258 </question>
   275 </question>
   259 
   276 
   260 <question>
   277 <question>
       
   278 <topic>Arrays and Matrices</topic>
   261 <description>
   279 <description>
   262 
   280 
   263 x = array([[1,2,3,4],
   281 x = array([[1,2,3,4],
   264            [3,4,2,5]])
   282            [3,4,2,5]])
   265 		 
   283 		 
   278 x\[ \: , -3 \: -1 \]
   296 x\[ \: , -3 \: -1 \]
   279 </expected_answer>
   297 </expected_answer>
   280 </question>
   298 </question>
   281 
   299 
   282 <question>
   300 <question>
       
   301 <topic>Arrays and Matrices</topic>
   283 <description>
   302 <description>
   284 What is the output of x[::3,::3]
   303 What is the output of x[::3,::3]
   285 </description>
   304 </description>
   286 <code>
   305 <code>
   287 In []: x = array([[9,18,27],
   306 In []: x = array([[9,18,27],
   295 9
   314 9
   296 </expected_answer>
   315 </expected_answer>
   297 </question>
   316 </question>
   298 
   317 
   299 <question>
   318 <question>
       
   319 <topic>Arrays and Matrices</topic>
   300 <description>
   320 <description>
   301 How do you get the transpose of this array?
   321 How do you get the transpose of this array?
   302 </description>
   322 </description>
   303 <code>
   323 <code>
   304 In []: a = array([[1, 2],
   324 In []: a = array([[1, 2],
   311 a\.T
   331 a\.T
   312 </expected_answer>
   332 </expected_answer>
   313 </question>
   333 </question>
   314 
   334 
   315 <question>
   335 <question>
       
   336 <topic>Arrays and Matrices</topic>
   316 <description>
   337 <description>
   317 What does this produce?
   338 What does this produce?
   318 </description>
   339 </description>
   319 <code>
   340 <code>
   320 In []: a = array([[1, 2],
   341 In []: a = array([[1, 2],
   331 \[ \[ 1 , 2 \] , \[ 6 , 8 \] \]
   352 \[ \[ 1 , 2 \] , \[ 6 , 8 \] \]
   332 </expected_answer>
   353 </expected_answer>
   333 </question>
   354 </question>
   334 
   355 
   335 <question>
   356 <question>
       
   357 <topic>Arrays and Matrices</topic>
   336 <description>
   358 <description>
   337 What command do you use to find the inverse of a matrix and its eigenvalues?
   359 What command do you use to find the inverse of a matrix and its eigenvalues?
   338 </description>
   360 </description>
   339 <time_limit>
   361 <time_limit>
   340 30
   362 30
   343 inv .* eigvals
   365 inv .* eigvals
   344 </expected_answer>
   366 </expected_answer>
   345 </question>
   367 </question>
   346 
   368 
   347 <question>
   369 <question>
       
   370 <topic>Solving linear equations</topic>
   348 <description>
   371 <description>
   349 Given a 4x4 matrix A and a 4-vector b , what command do you use to solve for the equation Ax = b ?
   372 Given a 4x4 matrix A and a 4-vector b , what command do you use to solve for the equation Ax = b ?
   350 </description>
   373 </description>
   351 <time_limit>
   374 <time_limit>
   352 45
   375 45
   355 solve \( A , b \)
   378 solve \( A , b \)
   356 </expected_answer>
   379 </expected_answer>
   357 </question>
   380 </question>
   358 
   381 
   359 <question>
   382 <question>
       
   383 <topic>Finding roots</topic>
   360 <description>
   384 <description>
   361 How do you calculate the roots of the polynomial, y = 1 + 6*x + 8*x^2 + x^3 
   385 How do you calculate the roots of the polynomial, y = 1 + 6*x + 8*x^2 + x^3 
   362 </description>
   386 </description>
   363 <time_limit>
   387 <time_limit>
   364 45
   388 45
   367 roots \( \[ 1 , 8 , 6 , 1 \] \)
   391 roots \( \[ 1 , 8 , 6 , 1 \] \)
   368 </expected_answer>
   392 </expected_answer>
   369 </question>
   393 </question>
   370 
   394 
   371 <question>
   395 <question>
       
   396 <topic>Solving linear equations</topic>
   372 <description>
   397 <description>
   373 Two arrays a and b are numerically almost equal, what command do you use to check if this is true?
   398 Two arrays a and b are numerically almost equal, what command do you use to check if this is true?
   374 </description>
   399 </description>
   375 <time_limit>
   400 <time_limit>
   376 30
   401 30
   380 allclose \( b , a \)
   405 allclose \( b , a \)
   381 </expected_answer>
   406 </expected_answer>
   382 </question>
   407 </question>
   383 
   408 
   384 <question>
   409 <question>
       
   410 <topic>Basic Datatypes</topic>
   385 <description>
   411 <description>
   386 What is the largest integer value that can be represented by Python?
   412 What is the largest integer value that can be represented by Python?
   387 </description>
   413 </description>
   388 <time_limit>
   414 <time_limit>
   389 30
   415 30
   398 No Limit
   424 No Limit
   399 </expected_answer>
   425 </expected_answer>
   400 </question>
   426 </question>
   401 
   427 
   402 <question>
   428 <question>
       
   429 <topic>Basic Datatypes</topic>
   403 <description>
   430 <description>
   404 What is the result of 17.0 / 2?
   431 What is the result of 17.0 / 2?
   405 </description>
   432 </description>
   406 <time_limit>
   433 <time_limit>
   407 15
   434 15
   410 8.5
   437 8.5
   411 </expected_answer>
   438 </expected_answer>
   412 </question>
   439 </question>
   413 
   440 
   414 <question>
   441 <question>
       
   442 <topic>Basic Datatypes</topic>
   415 <description>
   443 <description>
   416 Which of the following is not a type in Python?
   444 Which of the following is not a type in Python?
   417 </description>
   445 </description>
   418 <time_limit>
   446 <time_limit>
   419 30
   447 30
   429 </expected_answer>
   457 </expected_answer>
   430 </question>
   458 </question>
   431 
   459 
   432 
   460 
   433 <question>
   461 <question>
       
   462 <topic>Basic Datatypes</topic>
   434 <description>
   463 <description>
   435 How do you create a complex number with real part 2 and imaginary part 0.5 ?
   464 How do you create a complex number with real part 2 and imaginary part 0.5 ?
   436 </description>
   465 </description>
   437 <time_limit>
   466 <time_limit>
   438 30
   467 30
   442 complex \( 2 , 0\.5 \)
   471 complex \( 2 , 0\.5 \)
   443 </expected_answer>
   472 </expected_answer>
   444 </question>
   473 </question>
   445 
   474 
   446 <question>
   475 <question>
       
   476 <topic>Input and Output</topic>
   447 <description>
   477 <description>
   448 What is the difference between print x and print x,
   478 What is the difference between print x and print x,
   449 </description>
   479 </description>
   450 <time_limit>
   480 <time_limit>
   451 30
   481 30
   454 correct manually
   484 correct manually
   455 </expected_answer>
   485 </expected_answer>
   456 </question>
   486 </question>
   457 
   487 
   458 <question>
   488 <question>
       
   489 <topic>Input and Output</topic>
   459 <description>
   490 <description>
   460 What does 't' * 40 produce?
   491 What does 't' * 40 produce?
   461 </description>
   492 </description>
   462 <time_limit>
   493 <time_limit>
   463 30
   494 30
   472 tttttttttttttttttttttttttttttttttttttttt
   503 tttttttttttttttttttttttttttttttttttttttt
   473 </expected_answer>
   504 </expected_answer>
   474 </question>
   505 </question>
   475 
   506 
   476 <question>
   507 <question>
       
   508 <topic>Basic Datatypes</topic>
   477 <description>
   509 <description>
   478 What is the output?
   510 What is the output?
   479 </description>
   511 </description>
   480 <code>
   512 <code>
   481 In []: ', '.join(['a', 'b', 'c'])
   513 In []: ', '.join(['a', 'b', 'c'])
   488 'a, b, c'
   520 'a, b, c'
   489 </expected_answer>
   521 </expected_answer>
   490 </question>
   522 </question>
   491 
   523 
   492 <question>
   524 <question>
       
   525 <topic>Basic Datatypes</topic>
   493 <description>
   526 <description>
   494 What is the output?
   527 What is the output?
   495 </description>
   528 </description>
   496 <code>
   529 <code>
   497 In []: 47 % 3 
   530 In []: 47 % 3 
   503 2
   536 2
   504 </expected_answer>
   537 </expected_answer>
   505 </question>
   538 </question>
   506 
   539 
   507 <question>
   540 <question>
       
   541 <topic>Lists and Tuples</topic>
   508 <description>
   542 <description>
   509 How do you find the presence of an element x in the list a
   543 How do you find the presence of an element x in the list a
   510 </description>
   544 </description>
   511 <time_limit>
   545 <time_limit>
   512 30
   546 30
   515 x in a
   549 x in a
   516 </expected_answer>
   550 </expected_answer>
   517 </question>
   551 </question>
   518 
   552 
   519 <question>
   553 <question>
       
   554 <topic>Sets</topic>
   520 <description>
   555 <description>
   521 What is the output
   556 What is the output
   522 </description>
   557 </description>
   523 <code>
   558 <code>
   524 In []: set([1, 2, 8, 2, 13, 8, 9])
   559 In []: set([1, 2, 8, 2, 13, 8, 9])
   531 \[ 1 , 2 , 8 , 13 , 9 \]
   566 \[ 1 , 2 , 8 , 13 , 9 \]
   532 </expected_answer>
   567 </expected_answer>
   533 </question>
   568 </question>
   534 
   569 
   535 <question>
   570 <question>
       
   571 <topic>Dictionaries</topic>
   536 <description>
   572 <description>
   537 What is the output
   573 What is the output
   538 </description>
   574 </description>
   539 <code>
   575 <code>
   540 In []: a = {'a': 1, 'b': 2} 
   576 In []: a = {'a': 1, 'b': 2} 
   551 \{ \"a\" \: 10 , \'b\' \: 2 \}
   587 \{ \"a\" \: 10 , \'b\' \: 2 \}
   552 </expected_answer>
   588 </expected_answer>
   553 </question>
   589 </question>
   554 
   590 
   555 <question>
   591 <question>
       
   592 <topic>Lists and Tuples</topic>
   556 <description>
   593 <description>
   557 What is the value of a after executing this code.
   594 What is the value of a after executing this code.
   558 </description>
   595 </description>
   559 <code>
   596 <code>
   560 In []: a = [1, 2, 3] 
   597 In []: a = [1, 2, 3] 
   567 \[ 1 , 2 , 3 , 5 , 6 \]
   604 \[ 1 , 2 , 3 , 5 , 6 \]
   568 </expected_answer>
   605 </expected_answer>
   569 </question>
   606 </question>
   570 
   607 
   571 <question>
   608 <question>
       
   609 <topic>Lists and Tuples</topic>
   572 <description>
   610 <description>
   573 What is the output?
   611 What is the output?
   574 </description>
   612 </description>
   575 <code>
   613 <code>
   576 In []: a = (1, 2, 3)
   614 In []: a = (1, 2, 3)
   585 ERROR
   623 ERROR
   586 </expected_answer>
   624 </expected_answer>
   587 </question>
   625 </question>
   588 
   626 
   589 <question>
   627 <question>
       
   628 <topic>Functions</topic>
   590 <description>
   629 <description>
   591 What is the value of func(1), if
   630 What is the value of func(1), if
   592 </description>
   631 </description>
   593 <code>
   632 <code>
   594 def func(x, y=10):
   633 def func(x, y=10):
   601 2 20
   640 2 20
   602 </expected_answer>
   641 </expected_answer>
   603 </question>
   642 </question>
   604 
   643 
   605 <question>
   644 <question>
       
   645 <topic>Functions</topic>
   606 <description>
   646 <description>
   607 How many items can a function return ?
   647 How many items can a function return ?
   608 </description>
   648 </description>
   609 <time_limit>
   649 <time_limit>
   610 30
   650 30