# HG changeset patch # User nishanth # Date 1271890459 -19800 # Node ID b45bb982ae249507b5896efbbccf31818e0909ab # Parent 3be60e26e14f6ee922b2ea831150ced10640d7ff added few more questions diff -r 3be60e26e14f -r b45bb982ae24 question_bank.xml --- a/question_bank.xml Thu Apr 22 02:25:05 2010 +0530 +++ b/question_bank.xml Thu Apr 22 04:24:19 2010 +0530 @@ -3,40 +3,129 @@ -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)? +Describe the plot produced by the following code + + +30 + + +In []: x = linspace(0, 2*pi, 50) +In []: plot(x, cos(x), 'go') + + +Correct this question manually + + + + + +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? + + +30 + + +\%hist \%save + + + + + +How do you set the x and y labels of a plot to "x" and "sin(x)" ? + + +60 + + +xlabel \( \" x \" \) ylabel \( \"sin\(x\)\" \) +xlabel \( \" x \" \) ylabel \( \'sin\(x\)\' \) +xlabel \( \' x \' \) ylabel \( \"sin\(x\)\" \) +xlabel \( \' x \' \) ylabel \( \'sin\(x\)\' \) + + + + + +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)? 90 -xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1.5 , 1.5\) +xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1\.5 , 1\.5 \) + + + + + +How do you combine two lists a and b to produce one list? + + +30 + + +a \+ b + + + + + +If a = [1, 2, 5, 9] how do you add 10 to the end of this list ? + + +30 + + +a\.append \( 10 \) +a = a \+ \[ 10 \] +a \+= \[ 10 \] -If a = [1, 2, 5, 9] then what is the value of a[0:-1] +Write the code to read a file "data.txt" and print each line of it? -30 +60 -\[ 1 , 2 , 5 \] +correct this manually -A sample line from a Comma Separated Values (CSV) file: -line = "Rossum, Guido, 42, 56, 34, 54" +The following code snippet has an error/bug. +What is the error? + + +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) + + +60 + + +plot + + + + + +"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? 30 -line\.split \( \" , \" \) -line\.split \( \' , \' \) +\.split \( " , " \) +\.split \( ' , ' \) @@ -52,6 +141,76 @@ + + +What is the output of the following code snippet + + +In [1]: d = { + 'a': 1, + 'b': 2 + } +In [2]: print d['c'] + + +30 + + +error +Error +ERROR + + + + + +Given the below dictionary, what command will you give to plot a pie-chart? + + +In []: sc = {'A': 10, 'B': 20, + 'C': 70} + + +60 + + +pie \( sc\.values \( \) \) +pie \( sc\.values \( \) , labels = sc\.keys \( \) \) + + + + + +Given the below marks, how will you calculate the mean? + + +In []: marks = [10, 20, 30, 50, 55, + 75, 83] + + +30 + + +mean \( marks \) +sum \( marks \) \/ len \( marks \) + + + + + +How will you convert the list marks to an array? + + +In []: marks = [10, 20, 30, 50, 55, 75, 83] + + +30 + + +array \( marks \) + + + diff -r 3be60e26e14f -r b45bb982ae24 quiz/management/commands/seed_que.py --- a/quiz/management/commands/seed_que.py Thu Apr 22 02:25:05 2010 +0530 +++ b/quiz/management/commands/seed_que.py Thu Apr 22 04:24:19 2010 +0530 @@ -2,7 +2,7 @@ from django.core.management.base import NoArgsCommand -from offline.quiz.models import QuestionBank +from offline.quiz.models import QuestionBank, Quiz name2num = {"day1quiz1" : "11", "day1quiz2" : "12", @@ -42,8 +42,6 @@ expected_ans = expected_ans, ) new_question.save() - - class Command(NoArgsCommand):