question_bank.xml
author nishanth
Thu, 22 Apr 2010 04:24:19 +0530
changeset 46 b45bb982ae24
parent 39 0fa055b8ea98
child 47 8a837762531b
permissions -rw-r--r--
added few more questions

<questionbank>
<day1quiz1>

<question>
<description>
Describe the plot produced by the following code
</description>
<time_limit>
30
</time_limit>
<code>
In []: x = linspace(0, 2*pi, 50)
In []: plot(x, cos(x), 'go')
</code>
<expected_answer>
Correct this question manually
</expected_answer>
</question>

<question>
<description>
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?
</description>
<time_limit>
30
</time_limit>
<expected_answer>
\%hist \%save
</expected_answer>
</question>

<question>
<description>
How do you set the x and y labels of a plot to "x" and "sin(x)" ?
</description>
<time_limit>
60
</time_limit>
<expected_answer>
xlabel \( \" x \" \) ylabel \( \"sin\(x\)\" \)
xlabel \( \" x \" \) ylabel \( \'sin\(x\)\' \)
xlabel \( \' x \' \) ylabel \( \"sin\(x\)\" \)
xlabel \( \' x \' \) ylabel \( \'sin\(x\)\' \)
</expected_answer>
</question>

<question>
<description>
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)?
</description>
<time_limit>
90
</time_limit>
<expected_answer>
xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1\.5 , 1\.5 \)
</expected_answer>
</question>

<question>
<description>
How do you combine two lists a and b to produce one list?
</description>
<time_limit>
30
</time_limit>
<expected_answer>
a \+ b
</expected_answer>
</question>

<question>
<description>
If a = [1, 2, 5, 9] how do you add 10 to the end of this list ?
</description>
<time_limit>
30
</time_limit>
<expected_answer>
a\.append \( 10 \)
a = a \+ \[ 10 \]
a \+= \[ 10 \]
</expected_answer>
</question>

<question>
<description>
Write the code to read a file "data.txt" and print each line of it?
</description>
<time_limit>
60
</time_limit>
<expected_answer>
correct this manually
</expected_answer>
</question>

<question>
<description>
The following code snippet has an error/bug.
What is the error?
</description>
<code>
In []: l = [0.1, 0.2, 0.3, 0.4]
In []: t = [0.69, 0.90, 1.19, 1.30]
In []: tsq = []
In []: for time in t:
 ....:     tsq.append(time*time)
 ....:     plot(l, tsq)
</code>
<time_limit>
60
</time_limit>
<expected_answer>
plot
</expected_answer>
</question>

<question>
<description>
"Rossum, Guido, 42, 56, 34, 54" is a sample line from a Comma Separated Values (CSV) file
What code would you use to separate the line into fields?
</description>
<time_limit>
30
</time_limit>
<expected_answer>
\.split \( " , " \)
\.split \( ' , ' \)
</expected_answer>
</question>

<question>
<description>
If a = [1, 2, 5, 9] how do you find the length of this list?
</description>
<time_limit>
30
</time_limit>
<expected_answer>
len \( a \)
</expected_answer>
</question>

<question>
<description>
What is the output of the following code snippet
</description>
<code>
In [1]: d = {
	  'a': 1,
	  'b': 2
	  }
In [2]: print d['c']
</code>
<time_limit>
30
</time_limit>
<expected_answer>
error
Error
ERROR
</expected_answer>
</question>

<question>
<description>
Given the below dictionary, what command will you give to plot a pie-chart?
</description>
<code>
In []: sc = {'A': 10, 'B': 20, 
             'C': 70}
</code>
<time_limit>
60
</time_limit>
<expected_answer>
pie \( sc\.values \( \) \)
pie \( sc\.values \( \) , labels = sc\.keys \( \) \)
</expected_answer>
</question>

<question>
<description>
Given the below marks, how will you calculate the mean?
</description>
<code>
In []: marks = [10, 20, 30, 50, 55, 
                75, 83] 
</code>
<time_limit>
30
</time_limit>
<expected_answer>
mean \( marks \)
sum \( marks \) \/ len \( marks \)
</expected_answer>
</question>

<question>
<description>
How will you convert the list marks to an array?
</description>
<code>
In []: marks = [10, 20, 30, 50, 55, 75, 83]
</code>
<time_limit>
30
</time_limit>
<expected_answer>
array \( marks \)
</expected_answer>
</question>

</day1quiz1>

<day1quiz2>
</day1quiz2>

</questionbank>