Quiz: Python Plotting with Matplotlib

Main.PythonQuiz9 History

Hide minor edits - Show changes to output

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:)
-->%red%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:)
-->%red%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:)
-->%red%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:)
-->%blue%Correct.%%
(:divend:)

->'''E.''' plot(y,x)

-->(:toggle hide q1e button show="Select":)
(:div id=q1e:)
-->%red%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:)
-->%red%Incorrect.%%  Blue solid line.
(:divend:)

->'''B.''' plt.plot(x,y,'k--')

-->(:toggle hide q2b button show="Select":)
(:div id=q2b:)
-->%blue%Correct.%%  Black dashed line.
(:divend:)

->'''C.''' plt.plot(x,y,'b--')

-->(:toggle hide q2c button show="Select":)
(:div id=q2c:)
-->%red%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:)
-->%blue%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:)
-->%blue%Correct.%%
(:divend:)

->'''C.''' Plots are often displayed in color on screens.

-->(:toggle hide q3c button show="Select":)
(:div id=q3c:)
-->%red%Incorrect.%% That statement is true, but does not explain why plots should be distinguished without color.
(:divend:)

----