Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a text box with a bounding box around the text.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.5, 0.5, 'Hello', bbox=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing color or fontsize directly to bbox instead of a dictionary.
Not using a dictionary for bbox parameter.
✗ Incorrect
The bbox parameter expects a dictionary defining the box style and face color to create a bounding box around the text.
2fill in blank
mediumComplete the code to set the bounding box style to 'circle' for the text box.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.3, 0.7, 'Circle Box', bbox=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'square' or 'round' instead of 'circle' for the boxstyle.
Not passing a dictionary to bbox.
✗ Incorrect
The 'circle' boxstyle creates a circular bounding box around the text with the specified face color.
3fill in blank
hardFix the error in the code to properly add a text box with a bounding box and a red edge color.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.6, 0.4, 'Edge Color', bbox=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'color' or 'bordercolor' instead of 'edgecolor'.
Not passing a dictionary to bbox.
✗ Incorrect
The correct key for the bounding box edge color is 'edgecolor'. Using 'color' or 'bordercolor' will not work.
4fill in blank
hardFill both blanks to create a text box with a shadow effect and a dashed edge.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.2, 0.8, 'Shadow Box', bbox=[1], [2]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting all keys in one dictionary instead of splitting into two.
Using solid line style instead of dashed.
✗ Incorrect
The first blank sets the box style and transparency for shadow effect, the second blank adds a dashed black edge.
5fill in blank
hardFill all three blanks to create a text box with a fancy box style, green face color, and bold font weight.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.4, 0.6, 'Fancy Box', bbox=[1], fontweight=[2], color=[3]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'normal' fontweight instead of 'bold'.
Not passing a dictionary to bbox.
Using wrong color strings.
✗ Incorrect
The bbox dictionary sets the fancy style and green color, fontweight is set to 'bold', and text color is black.