Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a title to the plot.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("My Plot") 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.
Forgetting to call plt.show() to display the plot.
✗ Incorrect
The title function adds a title to the plot.
2fill in blank
mediumComplete the code to label the x-axis.
Matplotlib
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.
Using title instead of xlabel.
✗ Incorrect
The xlabel function sets the label for the x-axis.
3fill in blank
hardFix the error in labeling the y-axis.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("Speed (m/s)") plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using xlabel instead of ylabel.
Using title instead of ylabel.
✗ Incorrect
The ylabel function sets the label for the y-axis.
4fill in blank
hardFill both blanks to add a title and label the x-axis.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("Sales Over Time") plt.[2]("Months") plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping xlabel and ylabel.
Using legend instead of title or xlabel.
✗ Incorrect
Use title to add a plot title and xlabel to label the x-axis.
5fill in blank
hardFill all three blanks to add a title, label the x-axis, and label the y-axis.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]("Temperature Change") plt.[2]("Day") plt.[3]("Degrees Celsius") plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up xlabel and ylabel.
Using grid instead of labels.
✗ Incorrect
Use title for the plot title, xlabel for the x-axis label, and ylabel for the y-axis label.