0
0
Matplotlibdata~10 mins

Inline display in Jupyter notebooks in Matplotlib - Interactive Code Practice

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

Complete the code to enable inline plotting in a Jupyter notebook.

Matplotlib
%[1] matplotlib inline
Drag options to blanks, or click blank then click option'
Amatplotlib
Bmatplotlib.pyplot
Cmatplotlib_inline
Dmatplotlib_inline.backend_inline
Attempts:
3 left
💡 Hint
Common Mistakes
Using '%matplotlib.pyplot inline' which is invalid.
Forgetting the % sign before the command.
Using '%matplotlib_inline' which is not a valid magic command.
2fill in blank
medium

Complete the code to import the plotting library commonly used with inline display.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Amatplotlib.pyplot
Bnumpy
Cpandas
Dseaborn
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy instead of matplotlib.pyplot.
Importing pandas which is for data manipulation, not plotting.
Importing seaborn without matplotlib.pyplot.
3fill in blank
hard

Fix the error in the code to display a simple plot inline.

Matplotlib
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]()
Drag options to blanks, or click blank then click option'
Aplot
Bdisplay
Cshow
Ddraw
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.display() which is not a valid function.
Using plt.plot() again instead of plt.show().
Using plt.draw() which is less common and may not display inline.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps numbers to their squares and filters for squares greater than 10.

Matplotlib
{x: x[1]2 for x in range(1, 6) if x[2]2 > 10}
Drag options to blanks, or click blank then click option'
A**
B%
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '%' instead of '**' for power.
Using '+' instead of '*' in the condition.
Mixing up operators causing wrong filtering.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths, filtering words longer than 3 characters.

Matplotlib
{ [1]: [2] for word in words if len(word) [3] 3 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' instead of 'word.upper()' for keys.
Using '<' instead of '>' in the condition.
Using 'word' instead of 'len(word)' for values.