Ip MS April Test - 22
Ip MS April Test - 22
General Instructions:
(i) All questions are compulsory.
(ii) This question paper has 2 Sections.
(iii) Section A has 10 MCQs numbered (1-10) carry 1 mark each.
(iv) Section B has 4 Descriptive Questions ( Q11 & 12 carry 2 marks each, Q13 &14 carry 3
marks each.
(v) Programming language: Python
SECTION A
1. NumPy is a group of elements of same type and is indexed by _____________. 1m
A. INTEGERS.
B. POSITIVE INTEGER
C. NEGATIVE INTEGER
D. BOTH POSITIVE & NEGATIVE INTEGERS
2. What is the shape of the following array? 1m
Arr1=np.array([ [3,6,2,8],[7,2,9,6] ])
A. (3, )
B. (3, 4)
C. (2, 4)
D. (4, 3)
3. What would be the output of np.zeros((2,3))? 1m
A. array([[0., 0., 0.], [0., 0., 0.]])
B. array([[0, 0, 0], [0, 0, 0]])
C. array([ 0., 0., 0., 0. ])
D. array( [0., 0., 0.], [0., 0., 0.] )
4. np.arange(1,10,2) will create array as___________ . 1m
A. array([1,2,3,4,5,6,7,8,9,10])
B. array([2,4,6,8,10])
C. array([1, 3, 5, 7, 9])
D. array([1, 3, 5, 7, 9, 11 ])
5. What would be the output of the following code? 1m
import numpy as np
a1=np.array([5,7,2,8,9,1])
a2=a1[2:4]
a2[1]=88
print(a1)
A. [5,7,2,8,9,1]
B. [5,7,2,88,9,1]
C. [5,7,2,8,88,1]
D. [5,7,88,8,9,1]
6. Choose the correct option that would display the elements in the 1st and 2nd column of the
given array myarray1. 1m
myarray1=numpy.array([[2.7,-2,-19],[0,3.4,99.9],[10.6,0,13]])
A. print(myarray1[1:3 , 0:2])
B. print(myarray1[ : , 1:2])
C. print(myarray1[0:3 , 1:2])
D. print(myarray1[ : , 0:2])
Expected output is :
[1 2 3 4 5]
sum= 15
A. [0.25 1. 2.5 7. ]
B. [0.25 1 2.5 7 ]
C. [ 1. 2.5 7. 8.5 ]
D. [0.25 1. 2.5 9. ]
10. Darsh, a student of class-XII has been assigned to create a pandas Series S1 as shown
below: 1m
a 100
b 200
c 300
d 400
e 500
dtype: int64
With reference to the above Series, choose the command that will give the following output:
A. print(S1[:3])
B. print(S1[0:3])
C. print(S1[1:3])
D. print(S1[2:4])
SECTION B
Q11. What would be the output? 2m
Output :
[1. 2. 3. 4.]
[ 4 9 16 25]
Each output line : 1m
Q12. Identify the errors and re-write the code given below: 2m
Identify errors:
import numpy #error1 as np
arr1=np.ones([2,3], datatype=int) #error2 dtype
print(arr1)
re-write code:
import numpy as np
arr1=np.ones([2,3], dtype =int)
print(arr1)
arr2=np. zeros((5, ))
Code:
import pandas as _______ # blank1
print(seriesCapCntry)
Output:
India NewDelhi
USA WashingtonDC
UK London
France Paris
dtype: object
Each blank : ½ m
Q14. a) What will be the output of the following code? 2m
import numpy as np
Arr = np.arange(1,11)
print(Arr[10:2:-2])
print(Arr[2:10:2])
Output :
[10 8 6 4]
[357 9]
Each output line : 1m
b) Differentiate between List and NumpyArray. 1m
1 diff : 1m