wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz 1.6

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

Which of the following is full form of NumPy?

a)

Number Python

b)

Numeric Python

c)

Numerical Python

d)

None of these

2.

Which of the function is a function to create a numpy array?

a)

empty()

b)

array()

c)

ones()

d)

All the above

3.

What is the output of the below code?

np.arange(2,8)

a)

array([2, 3, 4, 5, 6, 7])

b)

array([3, 4, 5, 6, 7])

c)

array([2, 3, 4, 5, 6, 7, 8])

d)

array([3, 4, 5, 6, 7, 8])

4.

Find the output of the below code.

a = np.array([[[1,2,3],[4,5,6]]])

print(a.ndim)

a)

1

b)

(1,3)

c)

3

d)

(3,1)

5.

Find the output of the below code.

a = np.array([[1,2,3],[4,5,6]])

print(a[1,2])

a)

6

b)

5

c)

2

d)

TypeError

6.

What is the output of the below code?

print(np.linspace(1,5,5))

a)

array([1. , 2.33333333, 3.66666667, 5. ])

b)

array([1., 2., 3., 4., 5.])

c)

array([1. , 1.8, 2.6, 3.4, 4.2, 5. ])

d)

None of the above

7.

Which of the following is code gives an error?

a)

a = np.array([(1,2,3),(4,5,6)]) a[(0,1)]

b)

a = np.array([(1,2,3),(4,5,6)]) a.reshape(2,4)

c)

a = np.array([(1,2,3),(4,5,6)]) a[np.arange(1), :]

d)

All the above

8.

What is the output of the below code?

print(np.zeros(5).dtype)

a)

int8

b)

int16

c)

uint8

d)

float64

9.

Which of the following is not true about the identity matrix?

a)

It is a square matrix

b)

It contains 1s in all the diagonals

c)

We can create an identity matrix using the identity() function

d)

None of the above

10.

What is the output of the below code?

np.array([[1,2,3],[4,5,6]]).ravel()

a)

array([1, 2, 3, 4, 5, 6])

b)

array([4, 5, 6, 1, 2, 3])

c)

array((1, 2, 3, 4, 5, 6))

d)

SyntaxError

11.

import numpy as np

arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])

print(arr.shape)

a)

2,4

b)

(2,4)

c)

(4,4)

d)

4,4

12.

import numpy as np

arr1 = np.array([1, 2, 3])

arr2 = np.array([4, 5, 6])

arr = np.concatenate((arr1, arr2))

print(arr)

a)

[1 2 3 4 5 6]

b)

[1 2 3 4 5]

c)

(1 2 3 4 5 6)

d)

[1, 2, 3, 4, 5, 6]