0
0
Matplotlibdata~10 mins

Why patterns solve common tasks in Matplotlib - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the matplotlib plotting library.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Amatplotlib.pyplot
Bseaborn
Cpandas
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like pandas or numpy.
Forgetting to import pyplot specifically.
2fill in blank
medium

Complete the code to create a simple line plot of y versus x.

Matplotlib
plt.[1](x, y)
plt.show()
Drag options to blanks, or click blank then click option'
Aplot
Bscatter
Chist
Dbar
Attempts:
3 left
💡 Hint
Common Mistakes
Using scatter which draws points but no lines.
Using hist which draws histograms.
3fill in blank
hard

Fix the error in the code to label the x-axis correctly.

Matplotlib
plt.xlabel([1])
Drag options to blanks, or click blank then click option'
Ax_label
B'x label'
Cxlabel
Dx label
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable name that is not defined.
Forgetting to put quotes around the label text.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths if length is greater than 3.

Matplotlib
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword.startswith('a')
Dword.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong condition in the if clause.
Mapping to the word itself instead of its length.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts if count is greater than 1.

Matplotlib
{ [1]: [2] for [3], [2] in word_counts.items() if [2] > 1 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Dword_counts
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable names in the loop.
Not converting the word to uppercase for the key.