-
Which of the following sequence data type is defined by enclosing the elements in parentheses ‘()’?
- Lists
- Arrays
- Tuples
- Dictionary
-
Which of the following statement is not valid about Numpy ‘Arrays’?
- The type of items in the array is specified by a separate data-type object (dtype)
- numpy arrays are immutable
- numpy arrays can support multidimensional data
- ndarray.shape attribute returns a tuple consisting of array dimensions
-
The command to access the last element from the array “a” is?
import array as arr
a = arr.array('d',[2.5,3.5,4.5])- print (a[0])
- print (a[3])
- print (a[-1])
- print (a)
-
Create an array ‘x’ with values 0 to 9 and find what is the command to extract the elements in the following sequence - array ([5,3,1])?
- x = np.arange(10); x[5,3,1]
- x = np.arange(10); x[-5::2]
- x = np.arange(10); x[5:-2]
- x = np.arange(10); x[5::-2]
-
What will be the output after executing the following codes?
x = (0,8,9,15,17,18)
y = slice(1,-2)
x[y]- 0,8,9,15
- 8,9,15,17
- 8,9,15
- IndexError
-
The method used to increase the length of the list by number of elements in its argument.
- add ()
- insert ()
- extend ()
- pop ()
-
The function that returns the indices of the sorted elements.
- np.argsort ()
- np.sort ()
- np.bogosort ()
- np.selectionsort ()
-
Create two tuples
tuple = (2,4,6,3,7)
Find out which of the following code does not work on a tuple
tuple1 = (1,2,3)- tuple+tuple1
- sum(tuple)
- tuple[3] = 45
- len(tuple)
-
The command to find the number of elements in the following array “N” is
N = np.array([24, None, 29, 'str', np.nan, 23, 20, (), [], ...])
- len(N)
- N.count()
- np.size(N)
- N.size()
-
Which of the following is not a valid syntax for creating a Set ‘M’ in Python?
- M = set ([11,12,12,13,14,15])
- M = {11,12,13,14}
- M = set ([11,12],[13,14],[14,15])
- M = set ((11,12,13,14))
-
What will be the output after executing the following codes?
S = {12,13,14,15}
S.intersection_update({17,13,14,16});
print(S)- Error, object has no attribute intersection_update
- S={12,13,14,15,16, 17}
- S={12,13,14,15}
- S={13,14}
-
Which of the following command returns the set of all elements from both sets, a and b?
- a ^ b
- a & b
- a | b
- a – b
-
What will be the output of ndarray.ndim attribute?
- Gives the size of each element of the array in bytes
- Gives the number of axes or dimensions of the array
- Gives the buffer containing the actual elements of the array
- Gives an object describing the type of the elements in the array
-
For dictionary d = {“plum ":0.66, "pears ":1.25,"oranges ":0.50, “apple”:0.75 }, which of the following statement correctly updates
the price of oranges to 0.90?
- d[2] = 0.90
- d[0.50] = 0.90
- d["oranges "] = 0.90
- d["plum "] = 0.90
-
Which of the following command(s) is/are used to join arrays?
- np.concatenate
- np.hstack
- np.vstack
- all of the above
-
What will be the output of the dictionary ‘c’?
c={}
c[1]=1
c['1']=2
c[1]+=1
print(c)- { 1: 1 }
- { 1: 2, '1': 2 }
- { 1: 0; ‘1’: 2 }
- { 1: 1, '1': 2 }
-
The output of the code given below is
n = [x*x for x in range(4)]
print(n)- [1, 4, 9]
- [1, 4, 9, 16]
- [0, 1, 4, 9]
- [0, 1, 4, 9, 16]
-
The output of the code given below is
list = [2, 4, 6, 8]
a = (x**3 for x in list)
print(next(a))- 4
- 6
- 8
- 64
-
Which of the following is not possible in sequence datatypes?
- Create a tuple inside a set
- Create a list inside a set
- Create a list inside a tuple
- Create a set inside a list
-
Which of the following commands will give you a new numpy array with Boolean values?
- np.ones((3,3),True)
- np.zeros((3,3),False)
- np.arange((3,3),False)
- np.full((3,3),True)
Python MCQ-2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment