# HG changeset patch
# User nishanth
# Date 1271894587 -19800
# Node ID 8a837762531b0eae2e2c3c22a52f7c0468940c08
# Parent b45bb982ae249507b5896efbbccf31818e0909ab
added all the day1 quiz2 questions
diff -r b45bb982ae24 -r 8a837762531b question_bank.xml
--- a/question_bank.xml Thu Apr 22 04:24:19 2010 +0530
+++ b/question_bank.xml Thu Apr 22 05:33:07 2010 +0530
@@ -146,10 +146,9 @@
What is the output of the following code snippet
-In [1]: d = {
- 'a': 1,
- 'b': 2
- }
+In [1]: d = {'a': 1,
+ 'b': 2
+ }
In [2]: print d['c']
@@ -167,8 +166,7 @@
Given the below dictionary, what command will you give to plot a pie-chart?
-In []: sc = {'A': 10, 'B': 20,
- 'C': 70}
+In []: sc = {'A': 10, 'B': 20, 'C': 70}
60
@@ -184,8 +182,7 @@
Given the below marks, how will you calculate the mean?
-In []: marks = [10, 20, 30, 50, 55,
- 75, 83]
+In []: marks = [10, 20, 30, 50, 55, 75, 83]
30
@@ -214,6 +211,181 @@
+
+
+
+What is the value of a after executing this code.
+
+
+In []: a = array([[1, 2],
+ [3, 4]])
+In []: a[1,0] = 0
+
+
+60
+
+
+\[ \[ 1 , 2 \] , \[ 0 , 4 \] \]
+
+
+
+
+
+What will be printed?
+
+
+In []: x = array(([1,2,3,4],
+ [2,3,4,5]))
+In []: x[-2][-3] = 4
+In []: print x
+
+
+90
+
+
+array \( \( \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \) \)
+array \( \[ \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \] \)
+\[ \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \]
+\( \[ 4 , 2 , 3 , 4 \] , \[ 2 , 3 , 4 , 5 \] \)
+
+
+
+
+
+If x = array([[1,2,3,4]]) How to change x to array([[1,2,0,4]]) ?
+
+
+60
+
+
+x\[ 0 \]\[ 2 \] = 0
+
+
+
+
+
+
+x = array([[1,2,3,4],
+ [3,4,2,5]])
+
+How do you get the following slice of x ?
+
+array([[2,3],
+ [4,2]])
+
+
+
+60
+
+
+x\[ \: , 1 \: 3 \]
+x\[ \: , 1 \: -1 \]
+x\[ \: , -3 \: -1 \]
+
+
+
+
+
+What is the output of x[::3,::3]
+
+
+In []: x = array([[9,18,27],
+ [30,60,90],
+ [14,7,1]])
+
+
+30
+
+
+9
+
+
+
+
+
+How do you get the transpose of this array?
+
+
+In []: a = array([[1, 2],
+ [3, 4]])
+
+
+30
+
+
+a\.T
+
+
+
+
+
+What does this produce?
+
+
+In []: a = array([[1, 2],
+ [3, 4]])
+In []: b = array([[1, 1],
+ [2, 2]])
+In []: a*b
+
+
+45
+
+
+array \( \[ \[ 1 , 2 \] , \[ 6 , 8 \] \] \)
+\[ \[ 1 , 2 \] , \[ 6 , 8 \] \]
+
+
+
+
+
+What command do you use to find the inverse of a matrix and its eigenvalues?
+
+
+30
+
+
+inv .* eigvals
+
+
+
+
+
+Given a 4x4 matrix A and a 4-vector b , what command do you use to solve for the equation Ax = b ?
+
+
+45
+
+
+solve \( A , b \)
+
+
+
+
+
+How do you calculate the roots of the polynomial, y = 1 + 6*x + 8*x^2 + x^3
+
+
+45
+
+
+roots \( \[ 1 , 8 , 6 , 1 \] \)
+
+
+
+
+
+Two arrays a and b are numerically almost equal, what command do you use to check if this is true?
+
+
+30
+
+
+allclose \( a , b \)
+allclose \( b , a \)
+
+
+