Unit 5: Data Visualization - Practice Quiz
1 What is Matplotlib mainly used for in Python?
2 Which module is commonly imported to create basic plots with Matplotlib?
3 What type of plot is best for showing a change in values over time?
4 Which Matplotlib function is commonly used to create a line plot?
5 What is a bar chart commonly used to compare?
6 Which Matplotlib function creates a vertical bar chart?
7 What does a scatter plot display?
8 Which Matplotlib function is used to create a scatter plot?
9 What does a pie chart show?
10 Which Matplotlib function is commonly used to create a pie chart?
11 What does a box-and-whisker plot help summarize?
12 Which value is represented by the line inside the box of a box plot?
13 What is a histogram mainly used to show?
14 What are the intervals in a histogram commonly called?
15 Why are multiple subplots used in one figure?
16 Which Matplotlib function can create a figure and a set of subplots?
17 What is Seaborn?
18 Which statement best describes Seaborn compared with Matplotlib?
19 Which Seaborn function is commonly used to create a scatter plot?
20 What is the main purpose of a dashboard?
21
Which code correctly uses Matplotlib's object-oriented interface to plot y against x and set the title?
fig = plt.subplots(); fig.plot(x, y); plt.set_title('Trend')
fig, ax = plt.subplots(); fig.plot(x, y); fig.set_title('Trend')
fig, ax = plt.subplots(); ax.plot(x, y); ax.set_title('Trend')
ax = plt.figure(); ax.plot(x, y); ax.title('Trend')
22 A program must compare monthly sales for two years on the same axes. Which approach is most appropriate?
ax.plot() twice with different labels, then call ax.legend()
ax.bar() twice at identical positions, then call ax.grid()
ax.hist() twice with equal bins, then call ax.legend()
ax.scatter() twice with one shared marker, then call ax.grid()
23
What is the usual visual effect if a y sequence passed to plt.plot() contains a NaN value between two valid observations?
24
Given x = np.arange(4) and width = 0.35, which positions produce side-by-side bars for two data series?
x and x + 2 * width
x - width and x - width/2
x / width and x * width
x - width/2 and x + width/2
25 A chart has long category names that overlap when placed on the horizontal axis. Which Matplotlib function is the most direct alternative?
plt.barh(categories, values)
plt.hist(categories, values)
plt.plot(categories, values)
plt.bar(categories, values)
26
In plt.scatter(x, y, s=population, c=income), what do s and c represent?
s controls line style and c controls axis color
s controls marker area and c controls marker color
s controls marker shape and c controls marker border
s controls transparency and c controls marker area
27 A scatter plot contains many overlapping points in the same region. Which change best reveals the density of overlapping observations?
alpha below 1
alpha to 1
28
Which argument adds percentage labels such as 25.0% to slices in a Matplotlib pie chart?
format='%1.1f%%'
autopct='%1.1f%%'
labels='%1.1f%%'
percent='%1.1f%%'
29
A Matplotlib box plot uses the default rule whis=1.5. Which statement best describes a point above the upper whisker?
30 Two groups have similar medians, but Group A has a much taller box than Group B. What does this most directly indicate?
31
The data are [0, 1, 2, 3, 4, 5]. Which call explicitly creates five equal-width bins covering the interval from 0 to 5?
plt.hist(data, bins=np.linspace(0, 5, 6))
plt.hist(data, bins=np.linspace(0, 5, 5))
plt.hist(data, bins=[0, 1, 2, 3, 4])
plt.hist(data, bins=np.arange(0, 5, 2))
32 When comparing samples of very different sizes, which option makes each histogram represent a probability density rather than raw counts?
cumulative=True
stacked=True
density=True
orientation='horizontal'
33
After fig, axes = plt.subplots(2, 3), which expression selects the axes in the second row and third column?
axes[2, 2]
axes[1, 3]
axes[2, 3]
axes[1, 2]
34 Four vertically arranged time-series subplots should use the same x-axis scale and tick positions. Which construction is most suitable?
plt.subplots(1, 4, constrained_layout=False)
plt.subplots(4, 1, sharex=True)
plt.subplots(4, 1, sharey=True)
plt.subplots(1, 4, squeeze=False)
35 Which statement correctly initializes a commonly used Seaborn theme before creating plots?
sns.create_theme(style='whitegrid')
sns.apply_style(theme='whitegrid')
sns.set_theme(style='whitegrid')
sns.plot_theme(name='whitegrid')
36 Which task most clearly demonstrates a typical advantage of Seaborn over basic Matplotlib commands?
hue and adding statistical estimates
37
A DataFrame df contains repeated sales observations for each region and quarter. Which call plots mean sales by quarter and uses separate colored lines for regions?
sns.scatterplot(data=df, x='quarter', y='region', hue='sales')
sns.histplot(data=df, x='sales', y='quarter', hue='region')
sns.lineplot(data=df, x='region', y='quarter', size='sales')
sns.lineplot(data=df, x='quarter', y='sales', hue='region')
38
You have a correlation matrix stored in corr. Which Seaborn call best displays its values in a color-coded grid with numeric annotations?
sns.pairplot(corr, annot=True, palette='coolwarm')
sns.heatmap(corr, annot=True, cmap='coolwarm')
sns.boxplot(corr, annot=True, color='coolwarm')
sns.histplot(corr, labels=True, cmap='coolwarm')
39 A researcher wants pairwise scatter plots for several numeric columns and distributions along the diagonal, separated by species color. Which call is most appropriate?
sns.pairplot(data=df, hue='species')
sns.relplot(data=df, hue='species')
sns.catplot(data=df, hue='species')
sns.displot(data=df, hue='species')
40 A team needs a Python dashboard in which changing a dropdown automatically updates a graph through declared input-output relationships. Which tool and feature best match this requirement?
41
Consider: fig, (ax1, ax2) = plt.subplots(1, 2); plt.sca(ax1); ax2.plot([0, 1], [2, 3]); plt.xlim(0, 5). Assuming no other commands intervene, which axes receives the new x-limits?
ax1 only
ax2.plot method disables subsequent pyplot state changes
ax1 and ax2
ax2 only
42
What is rendered by plt.plot([0, 1, 2, 3], [0, 1, np.nan, 3], marker='o') under Matplotlib's standard handling of missing values?
43
What is the key consequence of running plt.bar(['A', 'B', 'A'], [4, 5, 7]) without manually assigning numeric positions?
A replaces the first before any rectangular patches are constructed
A heights into one bar
A bars receive the same categorical x-position and overlap
A, B, and A
44 Two scatter calls display subsets of one variable using the same colormap. How should the calls be configured so that a value of always maps to the same color, even when the subsets have different ranges?
Normalize object and the same colormap to both calls
scatter
alpha and edgecolors values to both calls
45
Assuming a Matplotlib version supporting normalize, what does plt.pie([0.2, 0.3], normalize=False, autopct='%1.0f%%') produce?
40% and 60%
40% and 60%
20% and 30%
46
In ax.boxplot(data, whis=(5, 95)), how are the whiskers determined?
47
For data [0.2, 0.8, 1.2, 2.2], bins [0, 1, 3], and density=True, what are the two histogram heights?
0.25 and 0.25, because density divides every count only by the total number of observations
0.5 and 0.5
2.0 and 2.0
0.5 and 0.25
48
What is the shape of axs returned by fig, axs = plt.subplots(2, 1, squeeze=False)?
(1, 2)
(2,)
axs is always a Python list when one dimension equals one
(2, 1)
49
A DataFrame contains several score rows for each category. What does sns.barplot(data=df, x='category', y='score') display by default in modern Seaborn?
50 Which statement correctly distinguishes Seaborn figure-level and axes-level interfaces?
displot is a direct Matplotlib function re-exported by Seaborn, whereas histplot performs DataFrame reshaping before calling it
histplot manages a FacetGrid, while displot must receive an ax argument
displot manages its own figure, while histplot can draw on a supplied Matplotlib axes
51
For sns.histplot(data=df, x='value', hue='group', stat='density', common_norm=False), what is the intended normalization across hue groups?
52 A dashboard must update several linked charts when a user selects a region. Which architecture most directly supports this requirement?
plt.show() for each chart and relies on the operating system to synchronize user selections
53
Given x = [3, 1, 2] and y = [30, 10, 20], what path does plt.plot(x, y) draw?
54
To construct a correctly diverging stacked bar chart containing both positive and negative components, how should the bottom values generally be maintained?
55
In Matplotlib, scatter(..., s=...) interprets s as marker area in points squared. Approximately how must s change to double a circular marker's diameter?
s, because marker diameter rather than area is transformed by the display coordinate system
s by
s by
s by
56
Using the usual percentile calculation and whis=1.5, what does a box plot of [1, 2, 3, 4, 100] show?
-1 and 7, even though neither fence is an observed data value
2 and 4, with both 1 and 100 as fliers
1 and 4, with 100 as a flier
1 and 100, with no fliers
57
For a nonempty dataset with finite values, density=True, and cumulative=True, what should the final cumulative histogram height be, apart from floating-point error?
1, because the integrated density accumulates to total probability
58
In plt.subplots(2, 2, sharex='col'), which axes share x-axis properties?
59
A long-form DataFrame has repeated measurements with columns subject, time, and value. Which call draws one trajectory per subject without aggregating subjects at each time?
sns.lineplot(data=df, x='time', y='value', units='subject', estimator=None)
sns.lineplot(data=df, x='time', y='value', hue='subject', estimator='median', errorbar=('ci', 95))
sns.lineplot(data=df, x='subject', y='value', errorbar=None)
sns.lineplot(data=df, x='time', y='value', estimator='mean')
60 A dashboard receives millions of timestamped observations, but its chart is only 1200 pixels wide. Which strategy most effectively improves interactive latency while preserving the visible trend?
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →