Complete the code to set the x-axis tick labels to ['A', 'B', 'C'].
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.xticks([1, 2, 3], [1]) plt.show()
The plt.xticks() function sets the positions and labels of the x-axis ticks. Here, the labels are set to ['A', 'B', 'C'].
Complete the code to set the y-axis ticks at positions 0, 5, and 10.
import matplotlib.pyplot as plt plt.plot([0, 1, 2], [0, 5, 10]) plt.yticks([1]) plt.show()
The plt.yticks() function sets the positions of the y-axis ticks. Here, ticks are set at 0, 5, and 10.
Fix the error in the code to correctly set x-axis tick labels to ['Low', 'Medium', 'High'].
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [10, 20, 30]) plt.xticks([1, 2, 3], [1]) plt.show()
The plt.xticks() function requires the second argument to be a list of labels matching the tick positions. Using ['Low', 'Medium', 'High'] sets the labels correctly.
Fill both blanks to create a dictionary of word lengths for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3}
The dictionary comprehension maps each word to its length using len(word). The condition len(word) > 3 filters words longer than 3 letters.
Fill all three blanks to create a dictionary of uppercase words and their lengths for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] result = [1]: [2] for w in words if len(w) [3] 3}
The dictionary comprehension uses w.upper() as keys and len(w) as values. The condition len(w) > 3 filters words longer than 3 letters.