Lesson 1 of 14 · 10 min
What Is Python and How to Run It
Python is a programming language, which means it is a set of written instructions that a computer can carry out. You write those instructions as plain text, and a helper program called the Python interpreter reads them and does what they say. Because the wording looks close to everyday English, Python is one of the friendliest languages for a complete beginner to pick up.
Why Python for biology
Biology now produces enormous data files, such as DNA sequences, gene expression tables, and protein structures, that are far too big to inspect by hand. Python offers free, ready-made toolkits such as Biopython for sequences, pandas for tables, and NumPy for numbers, so you rarely have to build anything from scratch. That large scientific toolkit, plus its readable style, is why Python has become one of the most popular languages in bioinformatics.
Running code line by line
Python is an interpreted language, so the interpreter reads your instructions from top to bottom and carries them out one line at a time. It finishes the first line completely before moving on to the second, in the exact order you wrote them. If it reaches a line it cannot carry out, Python stops at that point and prints an error message describing what went wrong.
Three ways to run it
The interactive REPL, short for read-eval-print loop, starts when you type python3 in a terminal, a text window for commands, and it runs each line the instant you press Enter. A script is a plain text file whose name ends in .py, which you run all at once with a command such as python3 hello.py. A notebook, like Jupyter or Google Colab, runs your code in separate cells inside a web browser, letting you mix code, results, and notes on one page.
Your first program
The line below calls print, a built-in function that displays whatever you give it on the screen. The text inside the quotation marks is called a string, which is simply how Python stores words and other characters. The round brackets after print hold the value you want it to show.
print("Hello, DNA")Hello, DNA
Try it yourself: Open Google Colab in your browser, click New notebook, type print("Hello, RNA") into the first cell, and press Shift+Enter to run it. You should see Hello, RNA appear directly beneath the cell.