Quiz: Python Plotting with Matplotlib

Main.PythonQuiz9 History

Hide minor edits - Show changes to markup

May 17, 2022, at 02:47 AM by 136.36.4.38 -
Added lines 1-94:

(:title Quiz: Python Plotting with Matplotlib:) (:keywords quiz, test, Python, plot, graph, scatter, introduction, course:) (:description Learning assessment on Python plotting with Matplotlib.:)


1. How do you plot a function y = f(x) after the statement import matplotlib.pyplot as plt?

A. plot(x,y)
(:toggle hide q1a button show="Select":)

(:div id=q1a:)

Incorrect. Use plt.plot(x,y) instead to indicate that the plt package is used to create the plot.

(:divend:)

B. plt(x,y)
(:toggle hide q1b button show="Select":)

(:div id=q1b:)

Incorrect. Use plt.plot(x,y) to use the plot function.

(:divend:)

C. matplotlib.plot(x,y)
(:toggle hide q1c button show="Select":)

(:div id=q1c:)

Incorrect. Use plt.plot(x,y) with matplotlib.pyplot renamed as plt as a shortened name.

(:divend:)

D. plt.plot(x,y)
(:toggle hide q1d button show="Select":)

(:div id=q1d:)

Correct.

(:divend:)

E. plot(y,x)
(:toggle hide q1e button show="Select":)

(:div id=q1e:)

Incorrect. Switch the x and y and use plt. at the beginning.

(:divend:)


2. What is the symbol code for a black dashed line when plotting x and y?

A. plt.plot(x,y,'b-')
(:toggle hide q2a button show="Select":)

(:div id=q2a:)

Incorrect. Blue solid line.

(:divend:)

B. plt.plot(x,y,'k--')
(:toggle hide q2b button show="Select":)

(:div id=q2b:)

Correct. Black dashed line.

(:divend:)

C. plt.plot(x,y,'b--')
(:toggle hide q2c button show="Select":)

(:div id=q2c:)

Incorrect. Blue bashed line.

(:divend:)


3. Why is it important to create a plot with trends that can be distinguished without color? Other things like line style or width are needed to distinguish trends. Select all that apply.

A. Many people are color vision deficient.
(:toggle hide q3a button show="Select":)

(:div id=q3a:)

Correct. There are an estimated 300 million people in the world with color vision deficiency. 1 in 12 men are color blind (8%). 1 in 200 women are color blind (0.5%).

(:divend:)

B. Plots are often printed in black in white.
(:toggle hide q3b button show="Select":)

(:div id=q3b:)

Correct.

(:divend:)

C. Plots are often displayed in color on screens.
(:toggle hide q3c button show="Select":)

(:div id=q3c:)

Incorrect. That statement is true, but does not explain why plots should be distinguished without color.

(:divend:)