A. The plot will display inside the notebook cell.
B. No plot will display and no error occurs.
C. The plot will open in a separate window.
D. A syntax error will occur.
Solution
Step 1: Understand default matplotlib behavior without inline
Without %matplotlib inline, matplotlib opens plots in external windows by default.
Step 2: Analyze the code behavior
The code calls plt.show(), which triggers the plot window to open externally.
Final Answer:
The plot will open in a separate window. -> Option C
Quick Check:
No inline command = external window [OK]
Hint: No %matplotlib inline means external window [OK]
Common Mistakes:
Assuming plot shows inside notebook by default
Expecting syntax errors
Thinking no plot appears
4. You run %matplotlib inline in a Jupyter notebook but your plots still do not show inside the notebook. What is the most likely cause?
medium
A. You forgot to import matplotlib.pyplot as plt.
B. Your notebook does not support inline plotting.
C. You used plt.show() which disables inline plots.
D. You ran the magic command after plotting the graphs.
Solution
Step 1: Understand when to run %matplotlib inline
The magic command must be run before any plotting commands to enable inline display.
Step 2: Analyze the options
You ran the magic command after plotting the graphs. correctly identifies that running the magic after plotting will not show plots inline. Other options are less likely or incorrect.
Final Answer:
You ran the magic command after plotting the graphs. -> Option D
Quick Check:
Run magic before plotting [OK]
Hint: Run %matplotlib inline before plotting [OK]
Common Mistakes:
Running magic after plotting
Thinking plt.show() disables inline
Assuming import affects inline display
5. You want to create multiple plots in a Jupyter notebook cell and have them all display inline one after another. Which approach will work best?
hard
A. Run %matplotlib inline and call plt.show() after each plot.
B. Run %matplotlib inline before plotting, then create all plots without calling plt.show().
C. Run %matplotlib inline and call plt.show() only after the last plot.
D. Run %matplotlib inline once, then call plt.show() after each plot.
Solution
Step 1: Understand inline plotting with multiple plots
With %matplotlib inline, plots are automatically rendered and displayed inline at the end of the cell without needing plt.show().
Step 2: Evaluate options for correct usage
Run %matplotlib inline before plotting, then create all plots without calling plt.show(). is the standard best practice as plt.show() is unnecessary in inline mode.
Final Answer:
Run %matplotlib inline before plotting, then create all plots without calling plt.show(). -> Option B
Quick Check:
No plt.show() needed in inline mode [OK]
Hint: No plt.show() needed with %matplotlib inline [OK]
Common Mistakes:
Calling plt.show() after each plot (unnecessary)
Calling plt.show() only after the last plot
Thinking plt.show() is required for inline
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.