Skip to main contentSkip to solution

Given the following statement:

import matplotlib.pyplot as plt

'plt' in the above statement is ___ name.

Solution

✅ Correct Option: 2

The as keyword in import ... as ... gives the imported module a shorter alternative name. Here plt is an alias for matplotlib.pyplot, so matplotlib.pyplot.plot() can be written as plt.plot().


Option 3: plt does hold a reference to the module, but Python's term for a name given with as in an import is an alias, not a variable.

Option 4: plt refers to a module, not a function. The functions, such as plot(), are called through it as plt.plot().

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question