Complete the code to create a 2x2 grid of plots using matplotlib subplots.
fig, axes = plt.subplots([1], 2) plt.show()
The plt.subplots function takes the number of rows and columns. To create a 2x2 grid, we need 2 rows and 2 columns.
Complete the code to plot data on the first subplot in a 2x2 grid.
fig, axes = plt.subplots(2, 2) axes[[1], 0].plot([1, 2, 3], [4, 5, 6]) plt.show()
Subplots are indexed starting at 0. The first subplot is at index 0.
Fix the error in the code to create a facet grid with 3 rows and 1 column.
fig, axes = plt.subplots([1], 1) axes[0].plot([1, 2, 3], [3, 2, 1]) plt.show()
To create 3 rows and 1 column, the first argument to plt.subplots should be 3.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
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 counts if count is greater than 0.
result = { [1]: [2] for [3], [2] in data.items() if [2] > 0}The comprehension maps the uppercase key k.upper() to its value v for each key-value pair k, v in data.items() where the value is greater than 0.