NEW
Font size
WorksheetsPYTHON PROGRAMMING FOR DATA SCIENCE QUIZ
Total questions: 30
Worksheet time: 15mins
What is the primary purpose of the 'print()' function in Python?
To read a file
To display output to the console
To define a function
To create a variable
Which of the following is a valid way to create a list in Python?
list = {1, 2, 3}
list = (1, 2, 3)
list = <1, 2, 3>
list = [1, 2, 3]
What data type is used to store a collection of unique items in Python?
List
Dictionary
Tuple
Set
Which operator is used for exponentiation in Python?
^^
**
exp
^
What is the output of the expression '3 * 2 + 1'?
5
6
7
8
Which of the following is NOT a valid data type in Python?
Integer
String
Character
Float
What is the purpose of the 'if' statement in Python?
To create a loop
To define a function
To make decisions based on conditions
To import libraries
Which of the following methods can be used to read a file in Python?
read()
load()
fetch()
get()
What is the correct way to create a dictionary in Python?
dict = (key: value)
dict = [key: value]
dict = {key: value}
dict =
Which function is used to merge two data frames in Pandas?
join()
concat()
merge()
combine()
What does the 'groupby()' function do in Pandas?
Sorts data
Aggregates data based on a key
Joins two data frames
Filters data
What is the purpose of the 'pivot_table()' function in Pandas?
To create a summary table
To filter data
To sort data
To merge data frames
Which of the following is a characteristic of a tuple in Python?
Ordered
Mutable
Unordered
Dynamic
What is the output of the expression 'len([1, 2, 3])'?
4
3
1
2
Which of the following libraries is primarily used for numerical operations in Python?
Scikit-learn
Matplotlib
Numpy
Pandas
Which of the following is a method to plot a histogram in Matplotlib?
plt.scatter()
plt.plot()
plt.bar()
plt.hist()
What is the primary use of the 'DataFrame' in Pandas?
To visualize data
To perform mathematical operations
To store 2D data in tabular form
To store 1D data
Which of the following is a valid way to import the Pandas library?
import Pandas
import pandas as pd as p
import pandas as pd
from pandas import *
What is the output of the expression '5 // 2' in Python?
1
3
2
2.5
Which of the following is a method to remove a variable from the environment in Python?
del
remove()
clear()
delete()
What is the purpose of the 'indexing' feature in Pandas?
To filter data
To sort data
To merge data frames
To access specific rows and columns
Which of the following is a valid way to create a 2D Numpy array?
array = {1, 2, 3, 4}
array = [1, 2, 3, 4]
array = (1, 2, 3, 4)
array = [[1, 2], [3, 4]]
What is the output of the expression '3 == 3'?
Error
True
None
False
Which of the following is a method to plot a line graph in Matplotlib?
plt.line()
plt.graph()
plt.plot()
plt.chart()
What is the purpose of the 'apply()' function in Pandas?
To sort data
To merge data frames
To filter data
To apply a function along an axis of the DataFrame
Which of the following is a valid way to read a CSV file using Pandas?
pd.read_csv('file.csv')
pd.read.csv('file.csv')
pd.open_csv('file.csv')
pd.load_csv('file.csv')
What is the output of the expression 'len([1, 2, 3])'?
Error
4
3
2
Which of the following is a method to convert a list to a Numpy array?
np.arraylist()
np.array()
np.tolist()
np.convert()
What is the output of the expression '5 % 2' in Python?
0
2
3
1
Which of the following is a method to add a new column to a DataFrame in Pandas?
df.append_column()
df.add_column()
df.insert()
df.new_column()
