Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a title to the plot.
Data Analysis Python
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("My Plot Title") plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using xlabel or ylabel instead of title.
Trying to use legend to set the title.
✗ Incorrect
The title function adds a title to the plot.
2fill in blank
mediumComplete the code to add a label to the x-axis.
Data Analysis Python
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("Time (seconds)") plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ylabel instead of xlabel.
Trying to set the label with title or legend.
✗ Incorrect
The xlabel function adds a label to the x-axis.
3fill in blank
hardFix the error in the code to add a legend to the plot.
Data Analysis Python
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], label='Line 1') plt.[1]() plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'legends' instead of 'legend'.
Trying to call 'label()' to show the legend.
✗ Incorrect
The correct function to show the legend is legend().
4fill in blank
hardFill both blanks to add labels to both axes.
Data Analysis Python
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("Days") plt.[2]("Sales") plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping xlabel and ylabel.
Using title or legend instead of axis labels.
✗ Incorrect
xlabel sets the label for the x-axis, and ylabel sets the label for the y-axis.
5fill in blank
hardFill all three blanks to add a title, x-axis label, and legend to the plot.
Data Analysis Python
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], label='Revenue') plt.[1]("Monthly Revenue") plt.[2]("Month") plt.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up title and xlabel.
Forgetting parentheses on legend.
Using ylabel instead of xlabel.
✗ Incorrect
title adds the plot title, xlabel labels the x-axis, and legend() shows the legend.