WorksheetsPlay with Python Lib
Total questions: 30
Worksheet time: 5mins
What is a correct syntax to create a NumPy array?
np.createArray([1, 2, 3, 4, 5])
np.array([1, 2, 3, 4, 5])
np.object([1, 2, 3, 4, 5])
What is a correct syntax to check the number of dimensions in an array?
np.dim()
np.dim
np.ndim
np.ndim()
Which of the following arrays is a two dimensional (2-D) array?
42
[[1, 2, 3], [4, 5, 6]]
[1, 2, 3, 4, 5]
How we can change the shape of the Numpy array in python?
By Shape()
By reshape()
By ord()
By change()
How we can find the type of numpy array in python ?
arr.dtype
arr.ntype
arr.data_type
arr.type()
How we install Numpy in the system ?
install numpy
pip install python numpy
pip install numpy
pip install numpy python
It is possible to convert the Numpy array to list in python ?
yes
no
sometimes
none of the above
What is a correct syntax to print the first item of an array?
print(myArr[1])
print(myArr,1)
print(myArr[0])
What is a correct syntax to print the number 16 from the array below:
arr = np.array([[2,4,6,8,10], [12,14,16,18,20]])
print(arr[7, 2])
print(arr[3, 0])
print(arr[1, 2])
What is a correct syntax to print the numbers [9, 12, 15] from the array below:
arr = np.array([3,6,9,12,15,18,21])
print(arr[2:4])
print(arr[3:6])
print(arr[2:6])
print(arr[2:5])
Which syntax would print the array as in reverse order:
arr = np.array([1,2,3,4,5,6,7])
print(arr[3:])
print(arr[0:7])
print(arr[::-1])
print(arr[:-1:])
What is the use of the zeros() function in Numpy array in python ?
To make a Matrix with all element 0
To make a Matrix with all diagonal element 0
To make a Matrix with first row 0
None of the above
Which of the following counts the number of elements in Numpy array ?
count()
return()
shape()
size()
Which of the following is correct way to import the Numpy module in your program ?
import numpy
import numpy as np
All of the above
from numpy import *
Only one of the following statements is true when it comes to Views in NumPy, which one?
The view SHOULD NOT be affected by the changes made to the original array.
The view SHOULD be affected by the changes made to the original array.
Only one of the following statements is true when it comes to Copies in NumPy, which one?
The copy SHOULD be affected by the changes made to the original array.
The copy SHOULD NOT be affected by the changes made to the original array.
In NumPy, what does the SHAPE of an array mean?
The shape is the number of rows.
The shape is the number of columns
The shape is the number of elements in each dimension.
What is a correct syntax to return the shape of an array?
arr.shape
shape(arr)
arr.shape()
What is a correct method to join two or more arrays?
join()
concatenate()
array_join()
What is a correct method to split arrays?
vstack()
hstack()
array_split()
All the other 3 answers are correct
What is a correct method to search for a certain value in an array?
search()
where()
find()
What is a correct syntax to return the index of all items that has the value 4 from the array below:
arr = np.array([1,4,3,4,5,4,4])?
np.where(arr == 4)
arr.where()
arr.search(4)
What is a correct method to sort the elements of an array?
orderby()
order()
sort()
When using the NumPy random module, how can you return a random number from 0 to 100?
random.randint(100)
random.rand()
random.rand(100)
What is a correct syntax to mathematically add the numbers of arr1 to the numbers of arr2?
np.append(arr1, arr2)
sum(arr1, arr2)
np.add(arr1, arr2)
What is a correct syntax to subtract the numbers from arr1 with the numbers from arr2?
np.minus(arr1, arr2)
np.min(arr1, arr2)
np.sub(arr1, arr2)
np.substract(arr1, arr2)
What would be the answer of this cummulative summation in NumPy?
arr = np.array([1,2,3])
print(np.cumsum(arr))
[3 6 9]
[1 3 6]
[9]
[6]
mat1 = np.array([[1,2,3],[4,5,6], [7,8,9]])
print(np.add(mat1, 1))
[[ 2, 3, 4],
[ 5, 6, 7],
[ 8, 9, 10]]
[[ 2, 3, 4],
[ 4, 5, 6],
[ 7, 8, 9]]
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
mat = np.array([[14, 5, 8, 10, 3],
[ 5, 14, 5, 9, 14],
[ 7, 8, 2, 13, 4],
[ 9, 12, 3, 6, 8],
[14, 5, 12, 4, 11]])
print(mat[1:4, 2:])
[[ 5, 9, 14],
[ 2, 13, 4],
[ 3, 6, 8]]
[[ 8, 2, 13, 4]]
[[ 5, 9, 14],
[ 2, 13, 4],
[ 3, 6, 8],
[12, 4, 11]]
Which is not a python library?
numpy
tensorflow
keras
sqrt
