Loading Python Libraries

Loading Python Libraries

Python is an open source programming language. There is a base Python library assumed to handle all of you basic needs. Python being open source you can add functions and additional applications. These additional functions are called libraries. You can load more libraries into a Python session to give your python more abilities. Below are instructions on how to import a Python library.

Steps

  1. Open Python. Start menu underneath ‘P’.
  2. Input following code to import library. Example below is importing ‘scipy’ library.
    import scipy as sc
  3. Perform commands and actions with library. Submit programs.

Example 1

#Example below will import and use numpy library.
#Example will create a list of random numbers and sort them.

import numpy as np
x = np.random.random(10)
print("Original array:")
print(x)
x.sort()
print("Sorted array:")
print(x)

Note: You must install and load Python libraries every time you open a new Python session.