Unit 12: Data visualization - Practice Quiz
1 What is Seaborn primarily used for in Python?
2 Which import statement uses the conventional alias for Seaborn?
3 Seaborn is built on top of which Python plotting library?
4 Which type of data is Seaborn especially useful for exploring?
5 Which Seaborn function applies a default visual theme to plots?
6 Which Seaborn function can load one of the library's example datasets?
7 Which library generally provides a higher-level interface for statistical plotting?
8 Which library usually offers more detailed, low-level control over plot elements?
9 Which statement correctly describes the relationship between Seaborn and Matplotlib?
10 Which library commonly provides attractive default themes and color palettes with less configuration?
11 Can Seaborn and Matplotlib be used together in the same program?
12 Why might a beginner choose Seaborn for statistical graphics?
13 Which Seaborn function creates a scatter plot?
14 Which Seaborn function is commonly used to draw a line plot?
15 Which Seaborn function displays the distribution of a numeric variable using bins?
16 Which Seaborn function is used to create a box plot?
17 Which Seaborn function displays values in a color-coded matrix?
18 Which parameter commonly assigns plot colors according to a data variable?
19 Which Seaborn function shows the number of observations in each category?
20
In sns.scatterplot(data=df, x="height", y="weight"), what does the x parameter specify?
21 Which feature of Seaborn most directly simplifies plotting variables from a pandas DataFrame?
22
A program uses import seaborn as sns. Which call applies a Seaborn theme to subsequent plots?
sns.load_theme(style="whitegrid")
sns.set_theme(style="whitegrid")
sns.apply_style(theme="whitegrid")
sns.plot_theme(name="whitegrid")
23
Which data organization works most naturally with Seaborn's x, y, and hue semantic mappings?
24 A notebook needs larger labels and lines for a presentation. Which Seaborn setting is most appropriate?
sns.set_context("talk")
sns.set_style("ticks")
sns.despine(offset=10)
sns.color_palette("deep")
25 Why might a developer choose Seaborn over Matplotlib for comparing a numeric variable across categories?
26
After creating ax = sns.scatterplot(...), how should a custom title be added using Matplotlib's object-oriented interface?
plt.axes_title("Results")
ax.make_title("Results")
sns.title(ax, "Results")
ax.set_title("Results")
27
Which statement correctly compares sns.scatterplot() and sns.relplot(kind="scatter")?
Figure
scatterplot() is figure-level; relplot() is axes-level
scatterplot() is axes-level; relplot() is figure-level
28 A chart requires individually positioned annotations, custom arrows, and precise control of every axis element. Which approach is generally most suitable?
29 Why can Matplotlib commands usually customize a chart created by Seaborn?
30 A scatter plot must distinguish species by both color and marker shape. Which call performs this mapping?
sns.scatterplot(data=df, x="length", y="mass", bins="species", fill="species")
sns.scatterplot(data=df, x="length", y="mass", hue="species", style="species")
sns.scatterplot(data=df, x="length", y="mass", row="species", col="species")
sns.scatterplot(data=df, x="length", y="mass", size="species", alpha="species")
31 A DataFrame contains repeated time values for several devices. Which call draws one unaggregated line per device?
sns.lineplot(data=df, x="time", y="value", size="device", estimator="mean")
sns.lineplot(data=df, x="time", y="value", style=None, estimator="median")
sns.lineplot(data=df, x="time", y="value", hue="device", estimator=None)
sns.lineplot(data=df, x="time", y="value", hue=None, estimator="sum")
32 In a standard Seaborn box plot, what does a point plotted beyond a whisker usually represent?
33 A student wants to compare the distribution shape and quartiles of scores for several classes. Which plot is most suitable?
sns.violinplot(x="class", y="score", inner="quart")
sns.countplot(x="class", hue="score", stat="count")
sns.scatterplot(x="class", y="score", legend="full")
sns.lineplot(x="class", y="score", estimator="sum")
34 Which call compares two groups' distributions in one histogram while keeping both visible through transparency?
sns.histplot(data=df, x="value", weights="group", multiple="stack", alpha=1.0)
sns.histplot(data=df, x="value", hue="group", multiple="layer", alpha=0.5)
sns.histplot(data=df, x="value", hue="group", multiple="fill", alpha=1.0)
sns.histplot(data=df, x="group", hue="value", multiple="dodge", alpha=1.0)
35 A dataset has one row per customer, and the goal is to display how many customers belong to each membership type. Which function should be used?
sns.barplot(data=df, x="membership")
sns.countplot(data=df, x="membership")
sns.regplot(data=df, x="membership")
sns.lineplot(data=df, x="membership")
36 A bar plot should show the average salary for each department rather than the number of records. Which call is appropriate?
sns.histplot(data=df, x="department", weights="salary", stat="count")
sns.boxplot(data=df, x="department", y="salary", whis="mean")
sns.barplot(data=df, x="department", y="salary", estimator="mean")
sns.countplot(data=df, x="department", hue="salary", stat="count")
37
A correlation matrix should display values such as 0.87 inside its cells. Which call provides this result?
sns.heatmap(corr, labels=True, bins=2)
sns.heatmap(corr, annot=True, fmt=".2f")
sns.heatmap(corr, annot=False, fmt=".2f")
sns.heatmap(corr, values=True, precision=2)
38 Which visualization efficiently examines pairwise relationships among several numeric columns while coloring observations by category?
sns.heatmap(df, hue="category")
sns.boxplot(data=df, hue="category")
sns.countplot(data=df, hue="category")
sns.pairplot(df, hue="category")
39 A researcher wants separate scatter-plot panels for each region while using the same variable mappings. Which call is appropriate?
sns.regplot(data=df, x="income", y="spending", row="region", kind="scatter")
sns.scatterplot(data=df, x="income", y="spending", col="region", kind="scatter")
sns.relplot(data=df, x="income", y="spending", col="region", kind="scatter")
sns.histplot(data=df, x="income", y="spending", col="region", kind="scatter")
40
A table contains columns month, city, and temperature, with one observation per city-month pair. What should be done before creating a heatmap with months as rows and cities as columns?
41
A figure already contains two Matplotlib subplots created by fig, axs = plt.subplots(1, 2). Which call draws a Seaborn histogram specifically on the second subplot without creating another figure?
sns.displot(data=df, x="value", ax=axs[1])
sns.displot(data=df, x="value", figure=axs[1])
sns.histplot(data=df, x="value", figure=fig)
sns.histplot(data=df, x="value", ax=axs[1])
42
A dataset contains repeated measurements of score at each time. Which capability most directly distinguishes sns.lineplot from a basic plt.plot call?
43
What object is returned by ax2 = sns.scatterplot(data=df, x="x", y="y") when no ax argument is supplied?
Axes containing the plot
Figure containing the plot
FacetGrid containing one facet
44
An Axes and several artists have already been created before sns.set_theme(style="darkgrid") is called. Which statement best describes the effect?
45
A table has columns control, low_dose, and high_dose, with one measurement per row in each column. You need sns.relplot with treatment mapped to both hue and col. Which transformation is most appropriate?
relplot.
treatment and measurement variables.
46
Under current Seaborn defaults, what happens when sns.lineplot(data=df, x="time", y="response") receives many response observations at each time value?
47
A longitudinal dataset contains subject, time, and score. Which call draws one trajectory per subject without adding every subject identifier to the legend?
sns.lineplot(data=df, x="time", y="score", style="subject", errorbar=None)
sns.lineplot(data=df, x="time", y="score", hue="subject", estimator="mean")
sns.lineplot(data=df, x="time", y="score", units="subject", estimator=None)
sns.lineplot(data=df, x="time", y="score", size="subject", estimator="median")
48
In sns.histplot(data=df, x="value", hue="group", stat="density", common_norm=True), how are overlaid group densities normalized?
49
Consider sns.histplot(data=df, x="amount", bins=10, log_scale=True) where amount includes zero and positive values spanning several orders of magnitude. Which interpretation is correct?
50
What does g = sns.catplot(data=df, x="group", y="score", col="site", kind="box") return, and where should facet-wide customization be applied?
Axes; use methods such as g.set_xlabel().
Figure; use methods such as g.set_axis_labels().
FacetGrid; use methods such as g.set_axis_labels().
51
A custom plotting function expects a facet subset as data and receives column names through x and y. Which FacetGrid method is designed for this interface?
g.map_dataframe(custom_func, x="time", y="value")
g.pipe(custom_func, x="time", y="value", facet=True)
g.apply_dataframe(custom_func, "time", "value")
g.map(custom_func, "time", "value", data=df)
52
A categorical scatter plot uses numeric years 2000, 2005, and 2020 on the categorical axis. Which setting preserves the unequal numeric spacing instead of placing the years at ordinal positions 0, 1, and 2?
dodge="auto".
log_scale=False.
native_scale=True.
formatter=str.
53
A heatmap contains values from to and is drawn with sns.heatmap(data, center=0, cmap="vlag") but without vmin or vmax. What should be expected?
54
For a square correlation matrix corr, which mask hides only the entries strictly above the main diagonal while retaining the diagonal and lower triangle?
np.tril(np.ones_like(corr, dtype=bool), k=-1)
np.triu(np.ones_like(corr, dtype=bool), k=0)
np.triu(np.ones_like(corr, dtype=bool), k=1)
np.eye(len(corr), dtype=bool)
55
Which statement correctly describes sns.clustermap when integrating it into an existing Matplotlib layout?
Axes and returns that Axes.
ClusterGrid.
56
You need separate regression panels by region, with a regression line and scatter plot in each panel. Which choice uses Seaborn's appropriate abstraction directly?
plt.plot(data=df, x="x", y="y", col="region")
sns.residplot(data=df, x="x", y="y", facet="region")
sns.lmplot(data=df, x="x", y="y", col="region")
sns.regplot(data=df, x="x", y="y", col="region")
57
A FacetGrid maps sns.histplot over subsets with very different ranges. Automatic bin selection produces different bin edges in each panel, making heights hard to compare. What is the most reliable correction?
sharex=True and allow each facet to calculate its own bins.
bins to every facet.
58
Two separate scatter plots map the same numeric variable to hue, but each plot contains a different subset of its range. How can identical values be guaranteed to receive identical colors across both plots?
legend="full" and let each plot infer its own normalization.
hue_norm limits.
sns.color_palette() before each plot without assigning its result.
59
In sns.boxplot(data=df, x="group", y="value", whis=(5, 95)), what do the whisker endpoints represent?
60
A box plot and strip plot are overlaid on the same axes, both using hue="treatment". The legend contains duplicate entries. Assuming the box-plot legend should be retained, what is the cleanest preventive approach?
hue=None to both calls after drawing the artists.
legend=False to the overlaid strip-plot call.
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 →