Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to plot a solid line using matplotlib.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], linestyle=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using "--" which creates a dashed line instead of solid.
Using ":" which creates a dotted line.
✗ Incorrect
The linestyle "-" creates a solid line in matplotlib.
2fill in blank
mediumComplete the code to plot a dashed line using matplotlib.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], linestyle=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using "-" which creates a solid line instead of dashed.
Using ":" which creates a dotted line.
✗ Incorrect
The linestyle "--" creates a dashed line in matplotlib.
3fill in blank
hardFix the error in the code to plot a dotted line using matplotlib.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], linestyle=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using "-" or "--" which create solid or dashed lines instead of dotted.
Repeating the same option twice.
✗ Incorrect
The linestyle ":" creates a dotted line in matplotlib.
4fill in blank
hardFill both blanks to create a plot with a dashed line and label it 'Dashed'.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], linestyle=[1], label=[2]) plt.legend() plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong linestyle for dashed lines.
Labeling the line incorrectly.
✗ Incorrect
Use linestyle "--" for dashed line and label it "Dashed" for the legend.
5fill in blank
hardFill all three blanks to create a plot with a dotted line, label it 'Dotted', and set the line width to 2.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], linestyle=[1], label=[2], linewidth=[3]) plt.legend() plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong linestyle for dotted lines.
Forgetting to set the linewidth correctly.
✗ Incorrect
Use linestyle ":" for dotted line, label it "Dotted", and set linewidth to 2 for thicker line.