Complete the code to display an image using matplotlib.
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('image.png') plt.[1](img) plt.show()
The imshow function is used to display images in matplotlib.
Complete the code to overlay a red circle on the image at coordinates (50, 50).
import matplotlib.pyplot as plt import matplotlib.patches as patches fig, ax = plt.subplots() ax.imshow(img) circle = patches.Circle((50, 50), radius=10, color=[1], fill=False) ax.add_patch(circle) plt.show()
The color 'red' is used to draw the circle in red.
Fix the error in the code to correctly overlay text on the image at position (100, 100).
fig, ax = plt.subplots() ax.imshow(img) ax.text(100, 100, 'Hello', color=[1]) plt.show()
The color value must be a string in quotes, like 'red'.
Fill both blanks to create a scatter plot overlay on the image with blue points at x and y coordinates.
fig, ax = plt.subplots() ax.imshow(img) ax.scatter([1], [2], color='blue') plt.show()
The scatter plot needs x and y coordinate lists to plot points on the image.
Fill all three blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.
word_lengths = { [1]: [2] for [3] in words if len([3]) > 3 }The dictionary comprehension maps each word to its length using len(word). The loop variable is word.