wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PYTHON PROGRAMMING FOR DATA SCIENCE QUIZ

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

What is the primary purpose of the 'print()' function in Python?

a)

To read a file

b)

To display output to the console

c)

To define a function

d)

To create a variable

2.

Which of the following is a valid way to create a list in Python?

a)

list = {1, 2, 3}

b)

list = (1, 2, 3)

c)

list = <1, 2, 3>

d)

list = [1, 2, 3]

3.

What data type is used to store a collection of unique items in Python?

a)

List

b)

Dictionary

c)

Tuple

d)

Set

4.

Which operator is used for exponentiation in Python?

a)

^^

b)

**

c)

exp

d)

^

5.

What is the output of the expression '3 * 2 + 1'?

a)

5

b)

6

c)

7

d)

8

6.

Which of the following is NOT a valid data type in Python?

a)

Integer

b)

String

c)

Character

d)

Float

7.

What is the purpose of the 'if' statement in Python?

a)

To create a loop

b)

To define a function

c)

To make decisions based on conditions

d)

To import libraries

8.

Which of the following methods can be used to read a file in Python?

a)

read()

b)

load()

c)

fetch()

d)

get()

9.

What is the correct way to create a dictionary in Python?

a)

dict = (key: value)

b)

dict = [key: value]

c)

dict = {key: value}

d)

dict =

10.

Which function is used to merge two data frames in Pandas?

a)

join()

b)

concat()

c)

merge()

d)

combine()

11.

What does the 'groupby()' function do in Pandas?

a)

Sorts data

b)

Aggregates data based on a key

c)

Joins two data frames

d)

Filters data

12.

What is the purpose of the 'pivot_table()' function in Pandas?

a)

To create a summary table

b)

To filter data

c)

To sort data

d)

To merge data frames

13.

Which of the following is a characteristic of a tuple in Python?

a)

Ordered

b)

Mutable

c)

Unordered

d)

Dynamic

14.

What is the output of the expression 'len([1, 2, 3])'?

a)

4

b)

3

c)

1

d)

2

15.

Which of the following libraries is primarily used for numerical operations in Python?

a)

Scikit-learn

b)

Matplotlib

c)

Numpy

d)

Pandas

16.

Which of the following is a method to plot a histogram in Matplotlib?

a)

plt.scatter()

b)

plt.plot()

c)

plt.bar()

d)

plt.hist()

17.

What is the primary use of the 'DataFrame' in Pandas?

a)

To visualize data

b)

To perform mathematical operations

c)

To store 2D data in tabular form

d)

To store 1D data

18.

Which of the following is a valid way to import the Pandas library?

a)

import Pandas

b)

import pandas as pd as p

c)

import pandas as pd

d)

from pandas import *

19.

What is the output of the expression '5 // 2' in Python?

a)

1

b)

3

c)

2

d)

2.5

20.

Which of the following is a method to remove a variable from the environment in Python?

a)

del

b)

remove()

c)

clear()

d)

delete()

21.

What is the purpose of the 'indexing' feature in Pandas?

a)

To filter data

b)

To sort data

c)

To merge data frames

d)

To access specific rows and columns

22.

Which of the following is a valid way to create a 2D Numpy array?

a)

array = {1, 2, 3, 4}

b)

array = [1, 2, 3, 4]

c)

array = (1, 2, 3, 4)

d)

array = [[1, 2], [3, 4]]

23.

What is the output of the expression '3 == 3'?

a)

Error

b)

True

c)

None

d)

False

24.

Which of the following is a method to plot a line graph in Matplotlib?

a)

plt.line()

b)

plt.graph()

c)

plt.plot()

d)

plt.chart()

25.

What is the purpose of the 'apply()' function in Pandas?

a)

To sort data

b)

To merge data frames

c)

To filter data

d)

To apply a function along an axis of the DataFrame

26.

Which of the following is a valid way to read a CSV file using Pandas?

a)

pd.read_csv('file.csv')

b)

pd.read.csv('file.csv')

c)

pd.open_csv('file.csv')

d)

pd.load_csv('file.csv')

27.

What is the output of the expression 'len([1, 2, 3])'?

a)

Error

b)

4

c)

3

d)

2

28.

Which of the following is a method to convert a list to a Numpy array?

a)

np.arraylist()

b)

np.array()

c)

np.tolist()

d)

np.convert()

29.

What is the output of the expression '5 % 2' in Python?

a)

0

b)

2

c)

3

d)

1

30.

Which of the following is a method to add a new column to a DataFrame in Pandas?

a)

df.append_column()

b)

df.add_column()

c)

df.insert()

d)

df.new_column()