10 Questions
What is the output of below python list code ?
list1 = [6, 7, 12, 11, 10, 9]
list2 = list1 * 2
list2[7] = list2[8] + 2
print(list2[-7:-1])
[9, 6, 14, 12, 11, 10]
Which of the following option will produce below output?
list1= [5,20,7,8,1,6,12,36]
output:
[20, 8, 6, 36]
print(list1[1:8:2])
Which of the below code contains correct syntax to create 2D array with shape of (3, 4). Assume that “np” is the alias for numpy package.
np.array( [ [1, 2, 5, 1], [3,0.1, 4], [4,1,1,6] ] )
What is the output of below numpy creation code ?
x = np.array([ np.arange(3,12,2), np.arange(4,17,3) ])
print(x)
[[ 3, 5, 7, 9, 11],[ 4, 7, 10, 13, 16]]
Which of the below option represents the output of the code below:
x= np.array([
[3, 1, 0, 0],
[3, 0, 1, 7],
[4, 1, 2, 3],
[2, 3, 2, 1]])
index=1
z = x[ [index + 1,index], [ index - 1,index] ]
z
[4,0]
What is the output of below code ?
x = np.array([
[12, 12, 7, 14, 2, 3, 4, 4, 13, 1],
[ 7, 2, 5, 6, 14, 10, 3, 12, 7, 11],
[ 1, 6, 9, 13, 14, 3, 10, 4, 5, 4],
[ 2, 8, 1, 3, 7, 3, 1, 5, 7, 12]])
[ 7, 6, 3, 11 ]
Which of the below function(s) returns the maximum element in a given numpy array x ?
x[np.argmax(x)]
Which of the below code option throws error ?
x = np.array([[1,0], [2,3],[1,2] ])
y = np.array([[10,5,0], [1,0,6], [2,2,0]])
x.dot(y)
Which of the value is a valid option for the variable “a” in-order to solve the given linear equation ?
2x + 3y + 2z = 24
x + 3z = 16
x + y = 15
a = _________________________________
np.linalg.solve(a,b)
np.array([[2,3,2],[1,0,3],[1,1,0]])
What is the output of below numpy arithmetic operation code ?
x = np.array([
[5, 7, 8],
[10, 12, 5],
[4, 1, 0]])
y = np.array([2,5,3])
print( x + y – 2)
[[ 5, 10, 9], [10, 15, 6], [ 4, 4, 1]]
Test your knowledge on Numpy and Python Basics operations by predicting the output of a code snippet that performs manipulations including multiplication, assignment, and slicing.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free