AlgoMaster Logo

Data Science Essentials - Quiz

Last Updated: December 6, 2025

Data Science Essentials Exercises

31 quizzes

1
Code Completion

Create a NumPy array of 10 zeros for initializing a weight vector

python
1
weights = np.((10,))

Click an option to fill the blank:

2
Code Completion

Select the second column from a 2D NumPy array for further analysis

python
1
second_column = matrix[:, ]

Click an option to fill the blank:

3
Code Completion

Calculate the mean of all values in a NumPy array of daily temperatures

python
1
avg_temp = np.(temperatures)

Click an option to fill the blank:

4
Multiple Choice

Which statement best describes a key advantage of NumPy over Python lists for numerical data?

5
Multiple Choice

Given arr = np.array([[1, 2, 3], [4, 5, 6]]), what is arr.shape?

6
Multiple Choice

You have a large numeric dataset in a CSV file. Which Pandas function is typically used to load it into a DataFrame?

7
Multiple Choice

In a Pandas DataFrame df, which syntax selects the 'age' column as a Series?

8
Multiple Choice

Which Matplotlib function displays the plot window after creating a figure?

9
Multiple Choice

Which plot type is most appropriate to compare total sales across product categories?

10
Multiple Choice

Given this DataFrame: df, which expression filters rows where 'Revenue' is greater than 1000?

11
Multiple Choice

What does the axis=0 argument mean in np.mean(data, axis=0) for a 2D array?

12
Multiple Choice

Which DataFrame method is commonly used to compute summary statistics like mean and std for numeric columns?

13
Multiple Choice

You want to color bars differently for each category in a Matplotlib bar chart. Which parameter should you use?

14
Multiple Choice

Which Pandas method combines rows from two DataFrames based on a common key column (like a database join)?

15
Sequencing

Order the steps to load a CSV file into a Pandas DataFrame and plot a line chart of a 'sales' column over 'day'.

Drag and drop to reorder, or use the arrows.

16
Sequencing

Order the steps to compute the average rating per product using a Pandas DataFrame and a groupby operation.

Drag and drop to reorder, or use the arrows.

17
Output Prediction

What is the output of this NumPy code?

1import numpy as np
2arr = np.array([10, 20, 30, 40])
3print(arr[1] + arr[-1])
18
Output Prediction

What is the output of this Pandas code?

1import pandas as pd
2s = pd.Series([3, 5, 7], index=['a', 'b', 'c'])
3print(s['b'])
19
Output Prediction

What does this code print?

1import numpy as np
2m = np.array([[1, 2], [3, 4]])
3print(m.reshape((4,))[2])
20
Output Prediction

What is the output of this Matplotlib-related code?

1import matplotlib.pyplot as plt
2values = [1, 2, 3]
3plt.plot(values)
4print(len(values))
21
Output Prediction

What is the output of this Pandas DataFrame code?

1import pandas as pd
2data = {'A': [1, 2], 'B': [3, 4]}
3df = pd.DataFrame(data)
4print(df['A'].mean())
22
Bug Spotting

Find the bug in this NumPy code that normalizes a vector of features.

Click on the line(s) that contain the bug.

python
1
import numpy as np
2
 
3
def normalize_vector(features):
4
    total = np.sum(features)
5
    normalized = features / total
6
    return normalized
23
Bug Spotting

Find the bug in this Pandas code that filters high-value transactions.

Click on the line(s) that contain the bug.

python
1
import pandas as pd
2
 
3
def filter_high_value(df_transactions):
4
    condition = df_transactions['amount'] > 1000
5
    result = df_transactions.loc[condition, 'amount', 'customer_id']
6
    return result
24
Matching

Match the NumPy function to what it creates or computes.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

25
Matching

Match the visualization type to the most suitable use case.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

26
Fill in the Blanks

Complete the code to create a NumPy array of 100 evenly spaced values between 0 and 1 and compute their average.

python
1
import numpy as np
2
values = np.(0, 1, 100)
3
mean_value = np.(values)
4
print(mean_value)

Click an option to fill blank 1:

27
Fill in the Blanks

Complete the code to read a CSV file into a DataFrame and show the first 3 rows.

python
1
import pandas as pd
2
sales_df = pd.('sales.csv')
3
preview = sales_df.(3)
4
print(preview)

Click an option to fill blank 1:

28
Fill in the Blanks

Complete the code to filter rows where 'Profit' is positive and compute the average profit.

python
1
import pandas as pd
2
positive = df[df['Profit'] > 0]
3
avg_profit = positive['Profit'].()
4
print()

Click an option to fill blank 1:

29
Fill in the Blanks

Complete the code to create a bar chart of product sales using Matplotlib.

python
1
import matplotlib.pyplot as plt
2
products = ['A', 'B', 'C']
3
sales = [120, 150, 90]
4
plt.(products, sales, color='skyblue')
5
plt.('Product Sales')
6
plt.show()

Click an option to fill blank 1:

30
Hotspot Selection

Click the line that sets the x-axis label in this Matplotlib plot.

Click on the line to select.

python
1
import matplotlib.pyplot as plt
2
x = [1, 2, 3]
3
y = [2, 4, 6]
4
plt.plot(x, y)
5
plt.xlabel('Time (days)')
6
plt.ylabel('Value')
7
plt.title('Trend over time')
8
plt.show()
31
Hotspot Selection

Click the line that performs the grouping operation in this Pandas code.

Click on the line to select.

python
1
import pandas as pd
2
 
3
sales = pd.read_csv('sales.csv')
4
by_region = sales.groupby('region')
5
summary = by_region['revenue'].sum()
6
print(summary)

Premium Content

Subscribe to unlock full access to this content and more premium articles.