wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Numpy and Pandas

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

How to use numpy ?

a)

import numpy as np

b)

import pandas as pd

c)

import pyplot as plt

2.

Name the function used to create an array?

a)

np.aray()

b)

np.array()

c)

Np.array()

d)

np.arange()

3.

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

4.

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' ]

5.

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" ]

6.

Each location of an element in an array is called ______________

a)

Size

b)

Length

c)

Index

d)

Element

7.

One dimensional arrays are also known as _____________

a)

Vectors

b)

ndarray

c)

Matrices

d)

Subscript

8.

A=np.array([1,2,3,4],dtype=np.float64)

What is the itemsize of array 'A'?

a)

1

b)

4

c)

8

d)

16

9.

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

10.

We can do arithmetic operations in python list.

a)

True

b)

False

11.

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]

12.

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

a)

dtype

b)

typei

c)

type

d)

itype

13.

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

14.

What is the use of the size attribute in Numpy array in python ?

a)

It find the direction

b)

It find the shape

c)

It finds the number of items

d)

All of the above

15.

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

16.

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

17.

Numpy in the Python provides the

a)

Function

b)

Lambda function

c)

Type casting

d)

Array

18.

What is a correct syntax to create a NumPy array?

a)

np.createArray([1, 2, 3, 4, 5])

b)

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

c)

np.object([1, 2, 3, 4, 5])

19.

What is a correct syntax to print the numbers [3, 4, 5] from the array below:


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

a)

print(arr[2:5])

b)

print(arr[2:6])

c)

print(arr[2:4])

d)

print(arr[3:6])

20.

Pandas deals with following data structures

a)

Series

b)

Series and Data Frames

c)

Series, DataFrames and Panel

d)

None of Above

21.

DataFrame in pandas is

a)

1. dimensional array

b)

2. dimensional array

c)

3.dimensional array

d)

4.None of the above

22.

Which of the following object you get after reading CSV file?

a)

a) DataFrame

b)

b) Character Vector

c)

c) Panel

d)

d) All of the mentioned

23.

Which of the following library is similar to Pandas?

a)

a) NumPy

b)

b) RPy

c)

c) SciPy

d)

d) None of the mentioned

24.

Series can be created from

a)

Array

b)

Dictionary

c)

Scaler value

d)

All of them

25.

Full form of CSV file is

a)

Comma Separated Vault

b)

Comma Separated Value

c)

Common Separated Value

d)

Common System Value

26.

Not a function of Dataframe

a)

Head()

b)

Tail()

c)

loc()

d)

multi()

27.

Dataframe can contain multiple series

a)

True

b)

False

28.

Which function from the options given below can read the dataset from a large text file?

a)

read_json

b)

read_pickle

c)

read_hdf

d)

read_csv

29.

Which of the following can be used to make a Dataframe?

a)

Series

b)

DataFrame

c)

Structured ndarray

d)

All of the above

30.

For the concat(), if the axis=1, it will join the dataframes ...............

a)

vertically

b)

horizontally

31.

Which of the functions can be used to delete column/row from a DataFrame?

a)

pop()

b)

at()

c)

drop()

d)

iloc()

32.

To extract subset from Series,the following function is used

a)

row()

b)

column()

c)

loc()

d)

all

33.

Series in Pandas is

a)

1 Dimensional Array

b)

2 Dimensional array

c)

3 Dimensional array

d)

none of above

34.

Minimum number of argument we require to pass in pandas series ?

a)

0

b)

1

c)

2

d)

3

35.

In data science, which of the python library are more popular ?

a)

numpy

b)

pandas

c)

django

d)

none

36.

Which package should be needed for series

a)

Maths

b)

Statistic

c)

Pandas

d)

Random

37.

Full form of NaN is

a)

Not a Null

b)

Not a Number

c)

Not a Numeric

d)

None of these

38.

pandas is a:

a)

Data Structure

b)

Series

c)

Dataframe

d)

Library

39.

Write the output for the following:

import pandas as pd1

s = pd1.Series(5, index=[0, 1, 2, 3])

print(s)

a)

0 5

b)

0 5

1 5

2 5

3 5

dtype: int64

c)

1 5

2 5

2 5

4 5

dtype: int64

d)

0 5

1 5

2 5

3 5

dtype: object

40.

write the output:

import pandas as pd

s=pd.Series([1,2,3,4],index=['a','b','c','d'])

print(s.iloc[2:4])

a)

b 2

c 3

d 4

dtype: int64

b)

b 3

c 4

dtype: int64

c)

c 3

d 4

dtype: int64

d)

none of the above

41.

Give the output of the following code:


>>>import pandas as pd

>>>dict1 = {'AR' : 100, 'VR' : 200, 'AI' : 300}

>>>ser = pd.Series(dict1)

>>>print(ser[1])

a)

AR

b)

100

c)

VR

d)

200

42.

A series is a one-dimensional array which is labelled and can hold any data type.

a)

True

b)

False

43.

Pandas is an open-source ________ Library?

a)

Ruby

b)

Javascript

c)

Java

d)

Python

44.

What will be output for the following code?

import pandas as pd

s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])

print(s['a'])

a)

1

b)

2

c)

3

d)

4

e)

5

45.

Which of the following commands is used to install Pandas?

a)

pip install python-pandas

b)

pip install pandas

c)

python install python

d)

python install pandas

46.

Which of the following statements is false?

a)

Dataframe is size-mutable

b)

Dataframe is values mutable

c)

Dataframe is immutable

d)

Dataframe is capable to hold multiple types of data.

47.

Series is a one-dimensional labeled array capable of holding any data type.

a)

true

b)

false

48.

What library in python is used for plotting graphs?

a)

numpy

b)

pandas

c)

math

d)

matplotlib

49.

Series.head() will return how many rows.

a)

2

b)

3

c)

4

d)

5

50.

What does this line of code do?

a)

Returns unique values

b)

Checks duplicates

c)

Drops duplicates

d)

Checks index duplicates