Using Python packages
Python packages are sort of like the different Toolboxes in MATLAB; however, an important practical difference is that you don't always have access to them in your workspace. Instead, to use a Python package, you must import it explicitly.
You can import an entire package or just import a single function or module from a package. You can also alias a package name to something shorter on import.
# Import a package
import math
# Import a function from a package
from math import log
# Alias a package
import datetime as dt
Let's explore importing with the NumPy package, which lets you store and manipulate multi-dimensional arrays.
Este exercício faz parte do curso
Python for MATLAB Users
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Import the NumPy package
# Print the value of pi from the NumPy package
print(____.____)