Skip to main content

Python

Introduction to Python

Python is a high-level, interpreted programming language known for its simplicity and versatility. It is widely used in various fields, including web development, data analysis, machine learning, scientific computing, and automation. Python's extensive standard library and vibrant ecosystem of third-party packages make it a powerful tool for developers and researchers alike.

Python supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Its clean syntax and readability make it an excellent choice for beginners and experienced programmers. For more details, visit the official Python documentation.

Using Python with Modules

To use Python on the terrabyte HPC system, load the Python module with the following command:

# consider adding the module use line to your ~/.bashrc to always make terrabyte modules available 
module use /dss/dsstbyfs01/pn56su/pn56su-dss-0020/usr/share/modules/files/
module load python

Usage Examples

Once loaded, you can start the Python interpreter by typing:

python

Example 1: Check Python Version

To verify the installed version of Python:

python --version

Example 2: Run a Python Script

To execute a Python script, create a file named script.py with the following content:

print("Hello, Python!")

Run the script using:

python script.py

Example 3: Install a Python Package

To install a package, such as numpy, using pip:

pip install numpy

Example 4: Use Python for Data Analysis

To perform basic data analysis using pandas:

import pandas as pd

data = {'Name': ['Alice', 'Bob'], 'Age': [25, 30]}
df = pd.DataFrame(data)
print(df)

For additional usage instructions and configuration details, refer to the Python documentation.