WorksheetsAI Course Quiz: Python, NumPy, Pandas, OpenCV
Total questions: 65
Worksheet time: 38mins
What will be the output of the following code?
[1, 2, 3]
[2, 3, 4]
[2, 3]
[1, 2, 3, 4]
Which of the following is the correct way to handle exceptions in Python?
try-catch
try-except
catch-finally
handle-error
What is the output of this code?
[1] [2]
[1] [1, 2]
[1, 2] [1, 2]
Error
Which method is used to remove whitespace from both ends of a string?
trim()
strip()
remove()
clean()
What will len("Hello\nWorld") return?
10
11
12
9
Which of the following creates a dictionary comprehension correctly?
{x: x**2 for x in range(5)}
[x: x2 for x in range(5)]
{x, x2 for x in range(5)}
(x: x2 for x in range(5))
What is the output of this code?
"ef"
"de"
"cd"
"f"
Which function is used to get user input in Python 3?
raw_input()
input()
get_input()
read()
What will be the result of bool([])?
True
False
None
Error
Which of the following is NOT a valid variable name in Python?
_variable
variable2
2variable
variable_name
What will be the shape of the resulting array?
(3, 4, 2)
(2, 4, 3)
(12, 2)
(24,)
What is the output of this code?
[4, 10, 18]
32
[[4, 5, 6], [8, 10, 12], [12, 15, 18]]
Error
Which function creates an array with evenly spaced values over a specified range?
np.arange()
np.linspace()
np.logspace()
All of the above
What will np.array([1, 2, 3]).dtype return?
int32 (or int64)
float64
object
string
What is the output of this code?
[[1, 2], [3, 4]]
[[1, 3], [2, 4]]
[[4, 3], [2, 1]]
Error
Which function is used to change the shape of an array without changing its data?
np.shape()
np.resize()
np.reshape()
np.reform()
What will be the output?
[True, False, False, True, True]
[4, 5]
[3, 4]
Error
Which method returns the indices of maximum values along an axis?
np.max()
np.argmax()
np.maximum()
np.maxindex()
What is the result of np.array([1, 2, 3]) + 5?
[6, 7, 8]
[1, 2, 3, 5]
Error
11
Which function creates an identity matrix?
np.identity()
np.eye()
Both a and b
np.ones()
What will np.array([1, 2, 3]).ndim return?
0
1
2
3
Which function is used to concatenate arrays along an existing axis?
np.stack()
np.concatenate()
np.append()
All of the above
What will be the output?
1
2
3
Error
Which method is used to read a CSV file in pandas?
pd.read_csv()
pd.load_csv()
pd.import_csv()
pd.csv_read()
What is the output of this code?
(2, 3)
(3, 2)
(6,)
Error
Which method returns the first n rows of a DataFrame?
df.first()
df.head()
df.top()
df.start()
What will be the result?
4
3
1
Error
Which method is used to group DataFrame rows based on column values?
df.group()
df.groupby()
df.aggregate()
df.cluster()
What is the output?
1
2
3
Error
Which method is used to merge two DataFrames?
df.merge()
df.join()
pd.merge()
All of the above
What will df.info() provide?
Statistical summary
Data types and memory usage
First few rows
Column names only
Which method is used to apply a function to each element in a DataFrame?
df.apply()
df.map()
df.applymap()
Both a and c
What is the output?
1.0
2.0
3.0
6.0
Which method is used to reset the index of a DataFrame?
df.reset_index()
df.reindex()
df.set_index()
df.index_reset()
Which function is used to read an image in OpenCV?
cv2.load_image()
cv2.imread()
cv2.read_img()
cv2.open_image()
What does the flag cv2.IMREAD_GRAYSCALE do?
Loads image in color
Loads image in grayscale
Loads image with alpha channel
Loads image as binary
Which function displays an image in OpenCV?
cv2.show()
cv2.display()
cv2.imshow()
cv2.view()
What will be the shape of an RGB image loaded with OpenCV?
(height, width, 3)
(width, height, 3)
(3, height, width)
(height, width)
Which function is used to convert color spaces in OpenCV?
cv2.convert_color()
cv2.cvtColor()
cv2.change_color()
cv2.color_convert()
What does cv2.waitKey(0) do?
Waits for any key press indefinitely
Waits for 0 seconds
Closes all windows
Does nothing
Which function is used to resize an image?
cv2.resize()
cv2.scale()
cv2.size_change()
cv2.reshape()
What is the correct way to convert BGR to RGB?
cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
cv2.convert(img, 'RGB')
img[:,:,::-1]
Which function applies Gaussian blur to an image?
cv2.blur()
cv2.GaussianBlur()
cv2.gaussian()
cv2.smooth()
What does cv2.destroyAllWindows() do?
Closes the current window
Closes all OpenCV windows
Destroys the image
Clears memory
Which function creates a basic line plot?
plt.line()
plt.plot()
plt.draw()
plt.graph()
What will this code create?
Line plot
Scatter plot
Bar plot
Histogram
Which function adds a title to a plot?
plt.title()
plt.set_title()
plt.add_title()
plt.heading()
What does plt.xlabel() do?
Sets the x-axis label
Sets the x-axis limits
Sets the x-axis ticks
Sets the x-axis scale
Which function creates subplots?
plt.subplot()
plt.subplots()
Both a and b
plt.create_subplots()
What does plt.legend() do?
Creates a legend for the plot
Sets the plot title
Adds grid lines
Changes plot colors
Which function creates a histogram?
plt.hist()
plt.histogram()
plt.bar()
plt.frequency()
What does plt.grid() do?
Creates a new plot
Adds grid lines to the plot
Changes the plot background
Sets plot boundaries
What is the result of multiplying a 3×2 matrix with a 2×4 matrix?
3×4 matrix
2×2 matrix
6×8 matrix
Not possible
What is the determinant of the identity matrix of size 3×3?
0
1
3
9
Which property does NOT hold for matrix multiplication?
Associative
Commutative
Distributive
None of the above
What is the transpose of matrix [[1, 2], [3, 4]]?
[[1, 2], [3, 4]]
[[1, 3], [2, 4]]
[[4, 3], [2, 1]]
[[2, 1], [4, 3]]
What is the rank of a 4×4 identity matrix?
0
1
4
16
Which operation finds the length (magnitude) of a vector?
Dot product
Cross product
Norm
Determinant
What is the dot product of vectors [1, 2, 3] and [4, 5, 6]?
[4, 10, 18]
32
14
21
An orthogonal matrix has which property?
A × A^T = I
A × A = I
A^T = A
det(A) = 0
What will be the output of the following code:
22
44
66
88
What will be the output of the following code:
[5,7]
[5,6]
[6,8]
Error
What will be the output of the following code:
(100, 100), 128
(100, 100, 1), 128
(100, 100), 114
(100, 100), 132
What will be the output of the following code:
4, (2, 2), 14.0
2, (2,), 14
4, (2, 2), 14
1, (2, 2), 8.6
What will be the output of the following code:
True
False
Error
Depends on eigenvals
