Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Both statements import the pyplot module from the matplotlib library and alias it as "plt", but the syntax is slightly different.

The first statement uses the "from ... import" syntax to only import the specified submodule, "pyplot", from the "matplotlib" library. It then aliases the module as "plt" for convenience.

The second statement uses the "import ... as" syntax to import the entire "pyplot" submodule from the "matplotlib" library and alias it as "plt" for convenience.

In terms of functionality, there is no difference between the two statements. It is just a matter of personal preference and coding style.