Summary¶
Python on HPC¶
HPC centers have different quality of documentation: you are encouraged to file a support ticket to request better documentation.
To login to your HPC cluster via the terminal, one can use SSH as shown below, but the exact syntax differs per cluster:
To find and load your favorite Python version one can use the commands below, but the exact syntax differs per cluster:
Python is an interpreted language. This means that an interpreter reads my code, converts it to machine code and then runs that machine code.
The Python interpreter is started with:
The go-to text editor on an HPC cluster is called nano,
with emacs and vim being more advanced text editors.
nano can be started with:
To create a Python script, one can do:
To run a Python script, one can do:
Basic Python¶
How to Think Like a Computer Scientist: Learning with Python 3 is a fine book to start learning Python from.
To create a variable in Python, do:
To print a variable in Python, do:
To do exponentiation in Python, use **:
To use the modulo operator, %, which is useful to determine
if a number is odd/even/prime, in Python do:
To ask the user to give a number, use input:
To read a file, use open and readlines and close:
To write to a file, use open and readlines and close: