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.
Diese Übung ist Teil des Kurses
Python for MATLAB Users
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Import the NumPy package
# Print the value of pi from the NumPy package
print(____.____)