Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 11 MCQsData visualization
ECAP776 ·
60 questions. Pick an option to check it.
Question 1 of 60 · Introduction to matplotlib · Easy
Which Python module is commonly imported as plt for data visualization?
Not quite. Try another option.
Answer: matplotlib.pyplot
matplotlib.pyplot provides commonly used plotting functions and is usually imported as plt.
Question 2 of 60 · Introduction to matplotlib · Easy
Which statement correctly imports matplotlib.pyplot using its conventional alias?
Not quite. Try another option.
Answer: import matplotlib.pyplot as plt
The conventional alias for matplotlib.pyplot is plt.
Question 3 of 60 · Introduction to matplotlib · Easy
Which function displays a completed Matplotlib figure on the screen?
Not quite. Try another option.
Answer: plt.show()
plt.show() displays the figure containing the created plots.
Question 4 of 60 · Line plot · Easy
Which Matplotlib function creates a basic line plot?
Not quite. Try another option.
Answer: plt.plot()
plt.plot() plots data points and connects them with lines by default.
Question 5 of 60 · Line plot · Easy
What is a line plot commonly used to show?
Not quite. Try another option.
Answer: Changes over time
A line plot is useful for showing trends or changes across an ordered sequence such as time.
Question 6 of 60 · Line plot · Easy
Which function adds a label to the horizontal axis of a line plot?
Not quite. Try another option.
Answer: plt.xlabel()
plt.xlabel() sets the label displayed along the horizontal axis.
Question 7 of 60 · Multiple subplots in one figure · Easy
What is a subplot in Matplotlib?
Not quite. Try another option.
Answer: A plot within a figure
A subplot is an individual plotting area placed inside a larger figure.
Question 8 of 60 · Multiple subplots in one figure · Easy
Which function can create a figure and multiple axes at the same time?
Not quite. Try another option.
Answer: plt.subplots()
plt.subplots() creates a figure together with one or more axes for plotting.
Question 9 of 60 · Multiple subplots in one figure · Easy
In plt.subplots(2, 2), how many subplots are created?
Not quite. Try another option.
Answer: Four subplots
A grid with 2 rows and 2 columns contains subplots.
Question 10 of 60 · Bar chart · Easy
Which function creates a vertical bar chart in Matplotlib?
Not quite. Try another option.
Answer: plt.bar()
plt.bar() creates vertical bars representing values for different categories.
Question 11 of 60 · Bar chart · Easy
A bar chart is most suitable for comparing which type of data?
Not quite. Try another option.
Answer: Values across categories
Bar charts compare numerical values associated with distinct categories.
Question 12 of 60 · Bar chart · Easy
Which function creates horizontal bars in Matplotlib?
Not quite. Try another option.
Answer: plt.barh()
plt.barh() creates a bar chart whose bars extend horizontally.
Question 13 of 60 · Histogram · Easy
Which Matplotlib function creates a histogram?
Not quite. Try another option.
Answer: plt.hist()
plt.hist() groups numerical data into intervals and displays their frequencies.
Question 14 of 60 · Histogram · Easy
What do the bars in a histogram usually represent?
Not quite. Try another option.
Answer: Frequencies within intervals
Each histogram bar shows how many observations fall within a numerical interval.
Question 15 of 60 · Histogram · Easy
What does the bins argument control in a histogram?
Not quite. Try another option.
Answer: The number of intervals
The bins argument controls how the data range is divided into intervals.
Question 16 of 60 · Box and whisker plot · Easy
Which function creates a box and whisker plot?
Not quite. Try another option.
Answer: plt.boxplot()
plt.boxplot() displays a dataset using a box, whiskers, and possible outliers.
Question 17 of 60 · Box and whisker plot · Easy
What does the line inside the box of a standard box plot represent?
Not quite. Try another option.
Answer: The median
The line inside the box marks the median, or middle value, of the dataset.
Question 18 of 60 · Scatter plot · Easy
Which function creates a scatter plot in Matplotlib?
Not quite. Try another option.
Answer: plt.scatter()
plt.scatter() displays individual data points using their horizontal and vertical coordinates.
Question 19 of 60 · Scatter plot · Easy
What is a scatter plot commonly used to examine?
Not quite. Try another option.
Answer: A relationship between variables
A scatter plot helps reveal relationships or patterns between two numerical variables.
Question 20 of 60 · Pie charts · Easy
Which Matplotlib function creates a pie chart?
Not quite. Try another option.
Answer: plt.pie()
plt.pie() creates a circular chart divided into slices representing parts of a whole.
Question 21 of 60 · Introduction to matplotlib · Medium
Which code correctly imports Matplotlib's plotting interface using its conventional alias?
Not quite. Try another option.
Answer: import matplotlib.pyplot as plt
matplotlib.pyplot provides common plotting functions and is conventionally imported as plt.
Question 22 of 60 · Introduction to matplotlib · Medium
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?
Not quite. Try another option.
Answer: plt.show()
plt.show() displays all figures that have been created by the script.
Question 23 of 60 · Line plot · Medium
What does the following code plot?
plt.plot([1, 2, 3], [2, 4, 1], "r--o")
Not quite. Try another option.
Answer: A red dashed line with circle markers
In the format string, r means red, -- means dashed, and o specifies circle markers.
Question 24 of 60 · Line plot · Medium
A program must plot temperature values against the corresponding days and include a legend. Which code is correct?
The label argument names the plotted series, and plt.legend() displays that name in a legend.
Question 25 of 60 · Line plot · Medium
Given x = [1, 2, 3, 4], which value of y can be used directly in plt.plot(x, y)?
Not quite. Try another option.
Answer: [2, 4, 6, 8]
For a single line, the x and y sequences must contain the same number of corresponding values.
Question 26 of 60 · Multiple subplots in one figure · Medium
What is selected by plt.subplot(2, 3, 4)?
Not quite. Try another option.
Answer: The fourth plot in a two-row, three-column grid
subplot(2, 3, 4) creates or selects position 4 in a grid containing 2 rows and 3 columns.
Question 27 of 60 · Multiple subplots in one figure · Medium
After fig, axes = plt.subplots(2, 2), which expression accesses the subplot in the second row and first column?
Not quite. Try another option.
Answer: axes[1, 0]
NumPy-style indexing starts at zero, so row index 1 and column index 0 identify the second-row, first-column axes.
Question 28 of 60 · Multiple subplots in one figure · Medium
Labels in a figure containing several subplots overlap one another. Which Matplotlib call is designed to improve their spacing automatically?
Not quite. Try another option.
Answer: plt.tight_layout()
plt.tight_layout() adjusts subplot spacing to reduce overlap among titles, labels, and tick marks.
Question 29 of 60 · Bar chart · Medium
A store wants to compare sales for the categories Books, Games, and Music. Which command produces an appropriate vertical bar chart?
Not quite. Try another option.
Answer: plt.bar(categories, sales)
plt.bar() creates vertical bars and is suitable for comparing numerical values across discrete categories.
Question 30 of 60 · Bar chart · Medium
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?
Not quite. Try another option.
Answer: x + w
Shifting the second series by one bar width places each of its bars beside the corresponding first-series bar.
Question 31 of 60 · Bar chart · Medium
Which function should replace plt.bar() when category names are long and horizontal bars would improve readability?
Not quite. Try another option.
Answer: plt.barh()
plt.barh() creates a horizontal bar chart, leaving more horizontal space for long category labels.
Question 32 of 60 · Histogram · Medium
What is the main effect of changing bins=5 to bins=20 in plt.hist(data, bins=...) while keeping the data unchanged?
Not quite. Try another option.
Answer: The plot uses more, narrower intervals
Increasing the number of bins divides the data range into more intervals, which are generally narrower.
Question 33 of 60 · Histogram · Medium
Consider data = [1, 2, 2, 3, 8, 9] and bins with edges [0, 5, 10]. How many observations fall into the first bin?
Not quite. Try another option.
Answer: 4 observations
The first interval contains 1, 2, 2, and 3, giving a frequency of 4.
Question 34 of 60 · Histogram · Medium
Two datasets contain different numbers of observations. Which argument helps compare their histogram shapes using normalized area rather than raw counts?
Not quite. Try another option.
Answer: density=True
With density=True, Matplotlib scales the histogram so its total area is 1, supporting shape comparisons.
Question 35 of 60 · Box and whisker plot · Medium
In a standard box plot, what does the line drawn inside the box represent?
Not quite. Try another option.
Answer: The data median
The line inside the box marks the median, while the box spans the first and third quartiles.
Question 36 of 60 · Box and whisker plot · Medium
For a box plot, and . Using the rule, which value would be plotted as an upper outlier?
Not quite. Try another option.
Answer:
Here , so the upper fence is . A value of lies above it.
Question 37 of 60 · Scatter plot · Medium
A scatter plot shows heavy overlap among points. Which modification most directly makes dense regions easier to observe without changing point positions?
Not quite. Try another option.
Answer: Set alpha=0.3
A lower alpha makes points transparent, so overlapping points form visibly darker regions.
Question 38 of 60 · Scatter plot · Medium
In plt.scatter(x, y, s=sizes, c=values, cmap="viridis"), what does cmap="viridis" control?
Not quite. Try another option.
Answer: How values map to point colors
The c argument supplies color values, and cmap selects the color map used to represent them.
Question 39 of 60 · Pie charts · Medium
Given sizes = [50, 30, 20], which explode argument separates only the second slice from the center?
Not quite. Try another option.
Answer: explode=(0, 0.1, 0)
The second explode value corresponds to the second slice; a positive value moves that slice outward.
Question 40 of 60 · Pie charts · Medium
Which argument displays each pie slice's percentage with one digit after the decimal point?
Not quite. Try another option.
Answer: autopct="%1.1f%%"
autopct formats percentage labels; %1.1f requests one decimal place, and %% produces a percent sign.
Question 41 of 60 · Introduction to matplotlib · Hard
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?
Not quite. Try another option.
Answer: ax1, because calling ax2.plot does not change pyplot's current axes
plt.sca(ax1) selects ax1 as pyplot's current axes. Calling the object-oriented method ax2.plot does not change that selection, so plt.title modifies ax1.
Question 42 of 60 · Introduction to matplotlib · Hard
After fig = plt.figure() and plt.close(fig), assuming another reference to fig is retained, which statement is correct?
Not quite. Try another option.
Answer: Its number leaves plt.get_fignums(), but fig remains usable
plt.close(fig) removes the figure from pyplot's managed registry. It does not destroy an independently retained Python reference, which can still be inspected or saved.
Question 43 of 60 · Line plot · Hard
What visible result is produced by plt.plot([0, 1, 2, 3], [4, np.nan, 6, 7]) under normal linear-axis settings?
Not quite. Try another option.
Answer: Only the segment joining the points at and appears
A NaN breaks a line rather than being interpolated. The point at is isolated, while the valid consecutive points at and form a segment.
Question 44 of 60 · Line plot · Hard
Given x = [0, 2, 1, 3] and y = [0, 4, 1, 9], what does plt.plot(x, y) do?
Not quite. Try another option.
Answer: It connects points in their supplied order, including a backward segment
plot preserves input order. It connects to , then moves backward to before connecting to .
Question 45 of 60 · Line plot · Hard
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])?
Not quite. Try another option.
Answer: Exactly because explicitly setting limits disables x autoscaling
set_xlim(0, 10) fixes the x limits and turns off x-axis autoscaling. The later line is stored but lies outside the visible x range.
Question 46 of 60 · Multiple subplots in one figure · Hard
What does fig, axs = plt.subplots(1, 1, squeeze=False) guarantee about axs?
Not quite. Try another option.
Answer: It is a two-dimensional array with shape (1, 1)
Setting squeeze=False prevents singleton dimensions from being removed, so axs remains a two-dimensional array accessed as axs[0, 0].
Question 47 of 60 · Multiple subplots in one figure · Hard
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?
Not quite. Try another option.
Answer: Both axes have because the last assignment propagates
Shared x-axes synchronize their limits. Each assignment propagates across the shared group, so the final call on b determines both ranges.
Question 48 of 60 · Bar chart · Hard
What happens when plt.bar(["A", "A", "B"], [2, 5, 3]) is executed?
Not quite. Try another option.
Answer: The two A bars occupy the same categorical x-coordinate and overlap
Equal categorical strings map to the same numerical x-coordinate. Matplotlib draws both bars there without automatically aggregating or separating them.
Question 49 of 60 · Bar chart · Hard
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?
Not quite. Try another option.
Answer:
Each second bar starts at a and extends by its signed height b, so its other boundary is .
Question 50 of 60 · Bar chart · Hard
With ax.bar([2], [5], width=-0.8, align="edge"), which horizontal interval does the bar occupy?
Not quite. Try another option.
Answer: From to
With align="edge", the x value marks one edge. A negative width extends leftward, so the interval is .
Question 51 of 60 · Histogram · Hard
What bin counts are returned by plt.hist([0, 1, 2], bins=[0, 1, 2])?
Not quite. Try another option.
Answer: , because only the final bin includes its right endpoint
Histogram bins are half-open except for the last one: contains 0, while contains both 1 and 2.
Question 52 of 60 · Histogram · Hard
For data [0.2, 0.8, 2, 3], bins [0, 1, 4], and density=True, what are the two histogram heights?
Not quite. Try another option.
Answer:
Each bin contains two of four observations, but their widths are and . Density is count divided by total count and bin width, giving and .
Question 53 of 60 · Histogram · Hard
Data [0.2, 0.8, 1.5] have weights [1, 3, 2]. With bins [0, 1, 3] and density=True, what heights are produced?
Not quite. Try another option.
Answer:
The bins have total weights and , total weight , and widths and . Their densities are and .
Question 54 of 60 · Box and whisker plot · Hard
Using the default whis=1.5, where does the upper whisker end for the data [1, 2, 3, 4, 100]?
Not quite. Try another option.
Answer: At , the largest observation within the upper fence
Here , , and , so the upper fence is . The whisker ends at the largest actual value not exceeding , which is .
Question 55 of 60 · Box and whisker plot · Hard
For [1, 2, 3, 4, 100], what changes when showfliers=False is passed while the default whis is retained?
Not quite. Try another option.
Answer: The value remains excluded, but its flier marker is hidden
showfliers=False controls only whether flier artists are displayed. It does not alter quartiles, fences, or whisker endpoints.
Question 56 of 60 · Scatter plot · Hard
In plt.scatter, marker size s is measured in points squared. Ignoring edge effects, how must s change to double a marker's diameter?
Not quite. Try another option.
Answer: Multiply s by
Marker area is proportional to the square of its linear size. Doubling the diameter therefore requires four times the area and hence four times s.
Question 57 of 60 · Scatter plot · Hard
What is the likely interpretation of ax.scatter([0, 1, 2], [1, 2, 3], c=(0.2, 0.4, 0.6), cmap="viridis")?
Not quite. Try another option.
Answer: The tuple supplies three scalar values mapped separately through the colormap
A one-dimensional numeric c whose length matches the three points is treated as scalar color data. Use color=(0.2, 0.4, 0.6) or a two-dimensional single-row RGB array for one constant color.
Question 58 of 60 · Pie charts · Hard
What total angular span is drawn by ax.pie([0.2, 0.3], normalize=False)?
Not quite. Try another option.
Answer:
With normalization disabled, each value is interpreted as a fraction of a full circle. Their sum is , so the wedges occupy .
Question 59 of 60 · Pie charts · Hard
For ax.pie([1, 3], startangle=90, counterclock=False), at what angle is the midpoint ray of the first wedge?
Not quite. Try another option.
Answer:
The first wedge occupies one quarter of the circle, or . Starting at and moving clockwise to places its midpoint at .
Question 60 of 60 · Pie charts · Hard
What does explode=[0.2, 0] do in ax.pie([1, 1], explode=[0.2, 0])?
Not quite. Try another option.
Answer: It translates the first wedge outward by radii without changing its angle
An explode value offsets a wedge's center along its angular bisector by a fraction of the pie radius. It does not alter the wedge's proportion or angular span.
That's unit 11
Answer a few questions and your score shows up here.
Nearly through. Did unit 11 of ECAP776 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 11 of ECAP776 save you a night before the exam?
Then you can help keep it free for the next batch. 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.