wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Array in Python

Total questions: 45

Worksheet time: 24mins

Name
Class
Date
1.

__________ is a library used to create data structures and carry out scientific calculations.

a)

Python

b)

Numpy

c)

Pycharm

d)

Bar chart

2.

How to use numpy ?

a)

import numpy as np

b)

import pandas as pd

c)

import pyplot as plt

3.

Name the function used to create an array?

a)

np.aray()

b)

np.array()

c)

Np.array()

d)

np.arange()

4.

np.arange(2,8,1) ----> what output will be produced?

a)

2,3,4,5,6,7,8

b)

2,3,4,5,6,7,8,9

c)

2,3,4,5,6,7

d)

2,4,6,8

5.

np.array{[4,7]}

a)

[ 4 7 ]

b)

[ 4 5 6 7 ]

c)

[ 4 5 6 ]

d)

[ 1 2 3 4 5 6 7 ]

6.

names = np.array(["Reem" , "Salah" , "Haya" , "Maryam" , "Fatema"])

print(names[[2,3,4]])

Mark the right output from the below options

a)

[ 'Haya' 'Maryam' 'Fatema' ]

b)

[ 'Maryam' 'Haya' 'Fatema' ]

c)

[ 'Reem' 'Salah' 'Fatema' ]

d)

[ 'Reem' 'Salah' 'Haya' ]

7.

names = np.array(["Reem" , "Salah" , "Haya" , "Maryam" , "Fatema"])

names[2] = "Omar"

print(names)

Mark the right output from the below options

a)

[ "Reem" "Salah" "Haya" , "Maryam" "Fatema" ]

b)

[ "Reem" "Salah" "Omar" "Maryam" "Fatema" ]

c)

[ "Reem" "Haya" "Salah" "Maryan" "Fatema" ]

8.

Which among the below options is a vector?

a)
b)
c)
9.

What output will the image above produce?

a)

[ [ 65. 60. 70. 58.


1.70. 1.65. 1.72. 1.60. ]]

b)

[ [ 1.70. 1.65. 1.72. 1.60


65. 60. 70. 58. ] ]

10.

What does the word "appending" mean?

a)

adding something extra

b)

changing something

11.

What would be the output of the following code ?

a)

15 18 16 20 19


18 16 17 15 20

b)

[33, 34, 33, 35, 39]

c)

[ 15 18 16 20 19

18 16 17 15 20

33 34 33 35 39 ]

12.

2**2 ----- What output will this produce?

a)

2

b)

4

c)

8

d)

0

13.

Each location of an element in an array is called ______________

a)

Size

b)

Length

c)

Index

d)

Element

14.

Two dimensional arrays are also known as ______________

a)

Subscripts

b)

Matrices

c)

ndarray

d)

Vectors

15.

One dimensional arrays are also known as _____________

a)

Vectors

b)

ndarray

c)

Matrices

d)

Subscript

16.

b=np.array([[1,2,3,4],[5,6,7,8],[10,11,12,13]])

Write the value of b[2,1].

a)

3

b)

6

c)

10

d)

11

17.

We can do arithmetic operations in python list.

a)

True

b)

False

18.

x=np.array([9,4,2,7])

y=x+5

a)

[14 9 7 12]

b)

[14,9 ,7, 12]

c)

[13 8 6 12]

d)

[13,8 ,6 ,12]

19.

_______________ is used to change the dimension or shape of the array.(Select the code used for it.)

a)

shape

b)

reshape

c)

reshape()

d)

itemsize

20.

What multiplication sentence does this array show?

a)

4 X 8 = 32

b)

4 X 8 = 31

c)

5 X 8 = 32

d)

4 X 8

21.

How we can find the type of numpy array in python?

a)

dtype

b)

typei

c)

type

d)

itype

22.

what is the use of the zeros() function in Numpy array in python ?

a)

To make a Matrix with first row 0

b)

To make a Matrix with all element 0

c)

To make a Matrix with all diagonal element 0

d)

None of the above

23.

Which of the following is not valid to import the numpy module ?

a)

import numpy as np

b)

import numpy as n

c)

import numpy as p

d)

None of the above

24.

Which of the following find the maximum number in the Numpy array?

a)

max(array)

b)

array.max()

c)

array(max)

d)

None of the above

25.

x=np.array([10,20,30,40,50,60,70])

print(np.median(x))


Find the output

a)

35

b)

35.0

c)

40

d)

37.7

26.

Numpy in the Python provides the

a)

Function

b)

Lambda function

c)

Type casting

d)

Array

27.

What will be the output of the following code:

import numpy as np

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

b = a.sum(axis=1)

print (b)

a)

3

b)

12

c)

[3 12]

d)

[3 5 7]

28.

What Python package for Linear Algebra ?

a)

Matrix

b)

Array

c)

NumPy

d)

Pynum

29.
What is python?
a)
a programming language 
b)
DTP software 
c)
Spreadsheet software
d)
Computer 
30.

Which operator is used in python to import all modules from packages?

a)

. operator

b)

* operator

c)

-> symbol

d)

, operator

31.

What is the extension of python library modules?

a)

.mod

b)

.lib

c)

.code

d)

.py

32.

random.randrange(6)

a)

0,1,2,3,4,5,6

b)

1,2,3,4,5,6

c)

0,1,2,3,4,5

d)

1,2,3,4,5

33.

random.randint(3,8)

a)

4,5,6,7

b)

3,4,5,6,7

c)

3,4,5,6,7,8

d)

0,1,2,3,4,5,6,7,8

34.

random.uniform() requires two parameters

a)

True

b)

False

35.

random.random() generates a floating point number between _____ and ______

a)

1 and 2

b)

1 and 0

c)

0 and 1

d)

0 and 10

36.

Which of the following symbols means more than?

a)

<

b)

>

c)

==

d)

!=

37.

Which of the following would allow the user to enter data?

a)

elif

b)

output

c)

print

d)

input

38.

If you type 6//2 what result would you get in python.

a)

3.0

b)

4

c)

3

d)

0

39.

If you type 10/5 what result would you get in python?

a)

2

b)

2.0

c)

0

d)

15

40.

if you type print("4"+"9") what result would you get

a)

49

b)

13

c)

error

d)

0

41.

What is a variable?

a)

A named memory location

b)

a value

c)

a number

d)

a letter

42.

Which of the following would generate a random number?

a)

number =random.randit

b)

number=randon.randnt(0,100)

c)

number=random.randint(0,100)

d)

number=random(0,100)

43.

Which module is used to import math functions like 'ceil' , 'sqr' etc. ?

a)

math module

b)

functions module

c)

arithmatics module

d)

turtle module

44.

Which of the following data types cannot be edited, altered or called upon ?

a)

Lists

b)

Dictionaries

c)

Tuples

d)

Strings

45.

Just like 'if-else' statments, the while loop also has a 'else' statment

a)

True

b)

False

c)

False. But the 'for' loop has an else statment.