Complete the code to add a text annotation at coordinates (2, 3) on the plot.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.[1](2, 3, 'Point') plt.show()
The text function adds text at specified coordinates on the plot.
Complete the code to add an annotation with an arrow pointing to (2, 4) with text 'Max'.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.annotate('Max', xy=(2, 4), xytext=(3, 5), arrowprops=[1]) plt.show()
The arrowprops dictionary must include 'arrowstyle' to define the arrow style.
Fix the error in the code to correctly place an annotation with an arrow.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.annotate('Peak', xy=(3, 9), xytext=(2, 7), arrowprops=[1]) plt.show()
The arrowprops argument must be a dictionary. Option A is missing braces, and D uses an invalid key.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
words = ['data', 'science', 'ai', 'ml'] lengths = {word: [1] for word in words if [2]
The dictionary comprehension maps each word to its length using len(word). The condition filters words with length greater than 3 using len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths if length is greater than 2.
words = ['cat', 'dog', 'a', 'bird'] result = { [1]: [2] for w in words if [3] }
The dictionary comprehension uses w.upper() as keys, len(w) as values, and filters words with length greater than 2.