You are on page 1of 2

REVISION OF BASICS OF PYTHON

✘ 1. Which of the following is correct way to import the Numpy module in your program ?

Points: list(array) ✓
0/1 list.array
array.list ✘
None of the above

✓ 2. Which of the following is/are correct to get the size of


the array ?
Points:
>>> a = array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
1/1
None of the given
a.size ✓
a.shape
size(a) ✓

✘ 3. Which of the following statements create a dictionary?

Points: d = {}
0/1 d = {“john”:40, “peter”:45} ✘
d = {40:”john”, 45:”peter”}
All of the mentioned ✓

✘ 4. What Will Be The Output Of The Following Code


Snippet?
Points:
a = {(1,2):1,(2,3):2}
0/1
print(a[1,2])

Key Error ✘
1✓
{(2,3):2}
{(1,2):1}

✓ 5. Which of the following command can be used to find square of the elements in the 2nd row? Consider array >>> a = array([[0, 0,
0], [3, 4, 5], [0, 0, 0]]) Output should be >>> array([ 9, 16, 25])
Points:
1/1 a[-1] * a[-1]
a[1] * a[1] ✓
a[1:] * a[1:]
a[0] * a[0]

✘ 6. Which of the following is correct way to import the Numpy module in your program ?

Points: import numpy


0/1 import numpy as np ✘
from numpy import *
All of the above ✓
✓ 7. What will be the output for the following code - >>> list1 = [2, 33, 222, 14, 25] >>> list1[::-1]

Points: 25
1/1 [2, 33, 222, 14]
Error
[25, 14, 222, 33, 2] ✓

✓ 8. What will be the output?

Points: d = {"john":40, "peter":45}


1/1 print(list(d.keys()))

[“john”, “peter”]. ✓
[“john”:40, “peter”:45].
(“john”, “peter”)
(“john”:40, “peter”:45)

✘ 9. which of the following is/are correct to get last element of array? Consider array >>> a = array([2, 4, 6, 8, 10])

Points: a[-1] ✓
0/1 a[5] ✘
a[3]
a[4] ✓

✓ 10. Correct syntax of the reshape() function in Numpy array python is -

Points: array.reshape(shape)
1/1 reshape(shape,array)
reshape(array,shape) ✓
reshape(shape)

You might also like