Unit 11: Data visualization - Practice Quiz

ECAP776 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which Python module is commonly imported as plt for data visualization?

Introduction to matplotlib Easy
A. matplotlib.array
B. matplotlib.pyplot
C. matplotlib.data
D. matplotlib.table

2 Which statement correctly imports matplotlib.pyplot using its conventional alias?

Introduction to matplotlib Easy
A. from matplotlib import data
B. from pyplot import matplotlib
C. import matplotlib.pyplot as mpl
D. import matplotlib.pyplot as plt

3 Which function displays a completed Matplotlib figure on the screen?

Introduction to matplotlib Easy
A. plt.view()
B. plt.show()
C. plt.print()
D. plt.open()

4 Which Matplotlib function creates a basic line plot?

Line plot Easy
A. plt.scatter()
B. plt.plot()
C. plt.bar()
D. plt.hist()

5 What is a line plot commonly used to show?

Line plot Easy
A. Changes over time
B. Parts of a whole
C. Individual quartile values
D. Frequency in intervals

6 Which function adds a label to the horizontal axis of a line plot?

Line plot Easy
A. plt.legend()
B. plt.xlabel()
C. plt.ylabel()
D. plt.title()

7 What is a subplot in Matplotlib?

Multiple subplots in one figure Easy
A. A label below an axis
B. A file containing a chart
C. A color assigned to data
D. A plot within a figure

8 Which function can create a figure and multiple axes at the same time?

Multiple subplots in one figure Easy
A. plt.savefig()
B. plt.subplots()
C. plt.xlabel()
D. plt.legend()

9 In plt.subplots(2, 2), how many subplots are created?

Multiple subplots in one figure Easy
A. Six subplots
B. Eight subplots
C. Two subplots
D. Four subplots

10 Which function creates a vertical bar chart in Matplotlib?

Bar chart Easy
A. plt.pie()
B. plt.bar()
C. plt.boxplot()
D. plt.plot()

11 A bar chart is most suitable for comparing which type of data?

Bar chart Easy
A. Quartiles of a dataset
B. Points with two coordinates
C. Values across categories
D. Parts of one circle

12 Which function creates horizontal bars in Matplotlib?

Bar chart Easy
A. plt.hist()
B. plt.hlines()
C. plt.barh()
D. plt.hbar()

13 Which Matplotlib function creates a histogram?

Histogram Easy
A. plt.pie()
B. plt.hist()
C. plt.plot()
D. plt.bar()

14 What do the bars in a histogram usually represent?

Histogram Easy
A. Values for named categories
B. Pairs of coordinate values
C. Percentages of a circle
D. Frequencies within intervals

15 What does the bins argument control in a histogram?

Histogram Easy
A. The label of the axis
B. The size of the figure
C. The number of intervals
D. The title of the plot

16 Which function creates a box and whisker plot?

Box and whisker plot Easy
A. plt.boxplot()
B. plt.barh()
C. plt.scatter()
D. plt.subplots()

17 What does the line inside the box of a standard box plot represent?

Box and whisker plot Easy
A. The maximum
B. The range
C. The mean
D. The median

18 Which function creates a scatter plot in Matplotlib?

Scatter plot Easy
A. plt.hist()
B. plt.boxplot()
C. plt.scatter()
D. plt.barh()

19 What is a scatter plot commonly used to examine?

Scatter plot Easy
A. A total divided into slices
B. A relationship between variables
C. A frequency grouped into bins
D. A trend joined by lines

20 Which Matplotlib function creates a pie chart?

Pie charts Easy
A. plt.pie()
B. plt.bar()
C. plt.hist()
D. plt.plot()

21 Which code correctly imports Matplotlib's plotting interface using its conventional alias?

Introduction to matplotlib Medium
A. import pyplot.matplotlib as plt
B. from matplotlib import plt
C. import matplotlib as pyplot
D. import matplotlib.pyplot as plt

22 A script creates a plot successfully but no window appears when it is run outside a notebook. Which statement should normally be added after the plotting commands?

Introduction to matplotlib Medium
A. plt.render()
B. plt.open()
C. plt.display()
D. plt.show()

23 What does the following code plot?

plt.plot([1, 2, 3], [2, 4, 1], "r--o")

Line plot Medium
A. A red dashed line with circle markers
B. A red solid line with triangle markers
C. A red dotted line with square markers
D. A blue dashed line with circle markers

24 A program must plot temperature values against the corresponding days and include a legend. Which code is correct?

Line plot Medium
A. plt.plot(days, temperatures); plt.label("Temperature")
B. plt.plot(days, temperatures, label="Temperature"); plt.legend()
C. plt.line(days, temperatures, legend="Temperature"); plt.show()
D. plt.plot(temperatures, days, title="Temperature"); plt.legend()

25 Given x = [1, 2, 3, 4], which value of y can be used directly in plt.plot(x, y)?

Line plot Medium
A. [2, 4, 6, 8]
B. [[2, 4], [6, 8]]
C. [2, 4, 6]
D. [2, 4, 6, 8, 10]

26 What is selected by plt.subplot(2, 3, 4)?

Multiple subplots in one figure Medium
A. The fourth plot in a three-row, two-column grid
B. The second plot in a three-row, four-column grid
C. The third plot in a two-row, four-column grid
D. The fourth plot in a two-row, three-column grid

27 After fig, axes = plt.subplots(2, 2), which expression accesses the subplot in the second row and first column?

Multiple subplots in one figure Medium
A. axes[1, 0]
B. axes[1, 1]
C. axes[0, 1]
D. axes[2, 1]

28 Labels in a figure containing several subplots overlap one another. Which Matplotlib call is designed to improve their spacing automatically?

Multiple subplots in one figure Medium
A. plt.tight_layout()
B. plt.equal_layout()
C. plt.fixed_layout()
D. plt.merge_layout()

29 A store wants to compare sales for the categories Books, Games, and Music. Which command produces an appropriate vertical bar chart?

Bar chart Medium
A. plt.scatter(categories, sales)
B. plt.plot(categories, sales)
C. plt.bar(categories, sales)
D. plt.hist(categories, sales)

30 For grouped bars, the first series uses positions x and width w. Which positions should the second series use to place its bars immediately beside the first series?

Bar chart Medium
A. x + 2*w
B. x - w
C. x + w
D. x - 2*w

31 Which function should replace plt.bar() when category names are long and horizontal bars would improve readability?

Bar chart Medium
A. plt.barx()
B. plt.barh()
C. plt.horizontal()
D. plt.hbar()

32 What is the main effect of changing bins=5 to bins=20 in plt.hist(data, bins=...) while keeping the data unchanged?

Histogram Medium
A. The plot uses fewer, wider intervals
B. The plot uses more, narrower intervals
C. The data values are multiplied by four
D. The frequencies are converted to categories

33 Consider data = [1, 2, 2, 3, 8, 9] and bins with edges [0, 5, 10]. How many observations fall into the first bin?

Histogram Medium
A. 3 observations
B. 4 observations
C. 5 observations
D. 2 observations

34 Two datasets contain different numbers of observations. Which argument helps compare their histogram shapes using normalized area rather than raw counts?

Histogram Medium
A. scale="equal"
B. normalize="count"
C. frequency=True
D. density=True

35 In a standard box plot, what does the line drawn inside the box represent?

Box and whisker plot Medium
A. The minimum value
B. The data median
C. The maximum value
D. The arithmetic mean

36 For a box plot, and . Using the rule, which value would be plotted as an upper outlier?

Box and whisker plot Medium
A.
B.
C.
D.

37 A scatter plot shows heavy overlap among points. Which modification most directly makes dense regions easier to observe without changing point positions?

Scatter plot Medium
A. Set aspect="equal"
B. Set alpha=0.3
C. Set linewidth=3
D. Set marker="s"

38 In plt.scatter(x, y, s=sizes, c=values, cmap="viridis"), what does cmap="viridis" control?

Scatter plot Medium
A. How points connect into a line
B. How values map to point colors
C. How sizes map to point areas
D. How axes map to logarithmic scales

39 Given sizes = [50, 30, 20], which explode argument separates only the second slice from the center?

Pie charts Medium
A. explode=(0, 0.1, 0)
B. explode=(0.1, 0, 0)
C. explode=(0, 0, 0.1)
D. explode=(0.1, 0.1, 0)

40 Which argument displays each pie slice's percentage with one digit after the decimal point?

Pie charts Medium
A. autopct="%1.1f%%"
B. percent="%1.1f%%"
C. labels="%1.1f%%"
D. autopct="%1f%"

41 Consider: fig, (ax1, ax2) = plt.subplots(1, 2); plt.sca(ax1); ax2.plot([0, 1], [0, 1]); plt.title("T"). Which axes receives the title?

Introduction to matplotlib Hard
A. ax2, because plotting through an axes object makes it current
B. Both axes, because pyplot titles apply to every axes in a figure
C. ax1, because calling ax2.plot does not change pyplot's current axes
D. Neither axes, because plt.title requires an explicit axes argument

42 After fig = plt.figure() and plt.close(fig), assuming another reference to fig is retained, which statement is correct?

Introduction to matplotlib Hard
A. Its axes are deleted, but its figure number remains registered
B. Its artists are cleared, and its figure number is immediately reused
C. Its number stays registered, but its canvas becomes permanently unusable
D. Its number leaves plt.get_fignums(), but fig remains usable

43 What visible result is produced by plt.plot([0, 1, 2, 3], [4, np.nan, 6, 7]) under normal linear-axis settings?

Line plot Hard
A. One segment joins the points at and
B. Only the segment joining the points at and appears
C. The missing value is interpolated between its neighboring values
D. The entire line is omitted because one value is invalid

44 Given x = [0, 2, 1, 3] and y = [0, 4, 1, 9], what does plt.plot(x, y) do?

Line plot Hard
A. It sorts x but leaves y in its original order
B. It connects points in their supplied order, including a backward segment
C. It rejects the data because x is not monotonically increasing
D. It sorts both arrays by x before drawing the line

45 What is the final x-axis range after ax.plot([0, 1], [0, 1]); ax.set_xlim(0, 10); ax.plot([20, 30], [2, 3])?

Line plot Hard
A. Approximately because every new line triggers autoscaling
B. Exactly because the newest line replaces the previous limits
C. Approximately because default margins are reapplied
D. Exactly because explicitly setting limits disables x autoscaling

46 What does fig, axs = plt.subplots(1, 1, squeeze=False) guarantee about axs?

Multiple subplots in one figure Hard
A. It is a one-dimensional array with shape (1,)
B. It is a nested list whose only element is an Axes object
C. It is a scalar Axes object with no array dimensions
D. It is a two-dimensional array with shape (1, 1)

47 Consider fig, (a, b) = plt.subplots(2, 1, sharex=True); a.set_xlim(2, 8); b.set_xlim(0, 5). What are the final x limits?

Multiple subplots in one figure Hard
A. Both axes have because the first assignment wins
B. a has , while b retains automatic limits
C. a has , while b has
D. Both axes have because the last assignment propagates

48 What happens when plt.bar(["A", "A", "B"], [2, 5, 3]) is executed?

Bar chart Hard
A. A ValueError occurs because categorical labels must be unique
B. The second A is renamed automatically to create a separate category
C. The repeated A values are combined into one bar of height
D. The two A bars occupy the same categorical x-coordinate and overlap

49 For a = [3, -2, 4] and b = [-1, 5, -3], the calls ax.bar(x, a) and ax.bar(x, b, bottom=a) are made. What are the y-coordinates of the second bars' top boundaries?

Bar chart Hard
A.
B.
C.
D.

50 With ax.bar([2], [5], width=-0.8, align="edge"), which horizontal interval does the bar occupy?

Bar chart Hard
A. From to
B. From to
C. From to
D. From to

51 What bin counts are returned by plt.hist([0, 1, 2], bins=[0, 1, 2])?

Histogram Hard
A. , because every bin includes its right endpoint
B. , because the shared boundary is counted in both bins
C. , because only the final bin includes its right endpoint
D. , because the rightmost value is outside every bin

52 For data [0.2, 0.8, 2, 3], bins [0, 1, 4], and density=True, what are the two histogram heights?

Histogram Hard
A.
B.
C.
D.

53 Data [0.2, 0.8, 1.5] have weights [1, 3, 2]. With bins [0, 1, 3] and density=True, what heights are produced?

Histogram Hard
A.
B.
C.
D.

54 Using the default whis=1.5, where does the upper whisker end for the data [1, 2, 3, 4, 100]?

Box and whisker plot Hard
A. At , the numerical value of the upper fence
B. At , the largest observation within the upper fence
C. At , the maximum observation in the data
D. At , the midpoint between the median and maximum

55 For [1, 2, 3, 4, 100], what changes when showfliers=False is passed while the default whis is retained?

Box and whisker plot Hard
A. The value remains excluded, but its flier marker is hidden
B. The upper fence moves to the maximum because fliers are disabled
C. The upper whisker expands to include the hidden value
D. The value is removed before quartiles are calculated

56 In plt.scatter, marker size s is measured in points squared. Ignoring edge effects, how must s change to double a marker's diameter?

Scatter plot Hard
A. Multiply s by
B. Take the square root of s
C. Add to s
D. Multiply s by

57 What is the likely interpretation of ax.scatter([0, 1, 2], [1, 2, 3], c=(0.2, 0.4, 0.6), cmap="viridis")?

Scatter plot Hard
A. The tuple supplies three scalar values mapped separately through the colormap
B. All markers receive the constant RGB color (0.2, 0.4, 0.6)
C. The tuple controls marker opacity, edge width, and drawing order
D. The call fails because c accepts only color names or hexadecimal strings

58 What total angular span is drawn by ax.pie([0.2, 0.3], normalize=False)?

Pie charts Hard
A.
B.
C.
D.

59 For ax.pie([1, 3], startangle=90, counterclock=False), at what angle is the midpoint ray of the first wedge?

Pie charts Hard
A.
B.
C.
D.

60 What does explode=[0.2, 0] do in ax.pie([1, 1], explode=[0.2, 0])?

Pie charts Hard
A. It increases the first wedge's angle from to
B. It enlarges the first wedge's radius by while keeping its center fixed
C. It translates the first wedge outward by radii without changing its angle
D. It inserts an empty wedge between the two data wedges