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.data
B. matplotlib.pyplot
C. matplotlib.array
D. matplotlib.table

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

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

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

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

4 Which Matplotlib function creates a basic line plot?

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

5 What is a line plot commonly used to show?

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

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

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

7 What is a subplot in Matplotlib?

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

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

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

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

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

10 Which function creates a vertical bar chart in Matplotlib?

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

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

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

12 Which function creates horizontal bars in Matplotlib?

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

13 Which Matplotlib function creates a histogram?

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

14 What do the bars in a histogram usually represent?

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

15 What does the bins argument control in a histogram?

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

16 Which function creates a box and whisker plot?

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

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

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

18 Which function creates a scatter plot in Matplotlib?

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

19 What is a scatter plot commonly used to examine?

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

20 Which Matplotlib function creates a pie chart?

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

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

Introduction to matplotlib Medium
A. from matplotlib import plt
B. import matplotlib as pyplot
C. import pyplot.matplotlib as plt
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.display()
C. plt.show()
D. plt.open()

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 dotted line with square markers
C. A blue dashed line with circle markers
D. A red solid line with triangle 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, 8, 10]
D. [2, 4, 6]

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

Multiple subplots in one figure Medium
A. The second plot in a three-row, four-column grid
B. The fourth plot in a three-row, two-column grid
C. The fourth plot in a two-row, three-column grid
D. The third plot in a two-row, four-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, 1]
B. axes[2, 1]
C. axes[1, 0]
D. axes[0, 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.merge_layout()
B. plt.fixed_layout()
C. plt.tight_layout()
D. plt.equal_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.bar(categories, sales)
B. plt.scatter(categories, sales)
C. plt.plot(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 - w
B. x - 2*w
C. x + 2*w
D. x + w

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

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

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 data values are multiplied by four
B. The plot uses more, narrower intervals
C. The plot uses fewer, wider intervals
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. 2 observations
B. 5 observations
C. 4 observations
D. 3 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. frequency=True
B. density=True
C. normalize="count"
D. scale="equal"

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 alpha=0.3
B. Set linewidth=3
C. Set marker="s"
D. Set aspect="equal"

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

Scatter plot Medium
A. How values map to point colors
B. How points connect into a line
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.1, 0)
C. explode=(0, 0, 0.1)
D. explode=(0.1, 0, 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. labels="%1.1f%%"
C. autopct="%1f%"
D. percent="%1.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. Neither axes, because plt.title requires an explicit axes argument
B. ax2, because plotting through an axes object makes it current
C. Both axes, because pyplot titles apply to every axes in a figure
D. ax1, because calling ax2.plot does not change pyplot's current axes

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 number leaves plt.get_fignums(), but fig remains usable
B. Its number stays registered, but its canvas becomes permanently unusable
C. Its artists are cleared, and its figure number is immediately reused
D. Its axes are deleted, but its figure number remains registered

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. The missing value is interpolated between its neighboring values
B. The entire line is omitted because one value is invalid
C. One segment joins the points at and
D. Only the segment joining the points at and appears

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 sorts both arrays by x before drawing the line
C. It connects points in their supplied order, including a backward segment
D. It rejects the data because x is not monotonically increasing

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 default margins are reapplied
B. Exactly because the newest line replaces the previous limits
C. Exactly because explicitly setting limits disables x autoscaling
D. Approximately because every new line triggers 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 nested list whose only element is an Axes object
B. It is a one-dimensional array with shape (1,)
C. It is a two-dimensional array with shape (1, 1)
D. It is a scalar Axes object with no array dimensions

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 last assignment propagates
B. a has , while b retains automatic limits
C. Both axes have because the first assignment wins
D. a has , while b has

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 two A bars occupy the same categorical x-coordinate and overlap
C. The repeated A values are combined into one bar of height
D. The second A is renamed automatically to create a separate category

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 only the final bin includes its right endpoint
C. , because the shared boundary is counted in both bins
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 maximum observation in the data
C. At , the largest observation within the upper fence
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 whisker expands to include the hidden value
C. The value is removed before quartiles are calculated
D. The upper fence moves to the maximum because fliers are disabled

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. Multiply s by
C. Add to s
D. Take the square root of s

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. All markers receive the constant RGB color (0.2, 0.4, 0.6)
B. The call fails because c accepts only color names or hexadecimal strings
C. The tuple controls marker opacity, edge width, and drawing order
D. The tuple supplies three scalar values mapped separately through the colormap

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 inserts an empty wedge between the two data wedges
B. It increases the first wedge's angle from to
C. It translates the first wedge outward by radii without changing its angle
D. It enlarges the first wedge's radius by while keeping its center fixed