Chapter 2Language Basics
In this chapter we introduce the basics of Python programming with variables and expressions. Fundamental Python data types are described along with how they may be combined into expressions using operators and global functions.
2.1 Python Interactive Console
Even if you never write a complete Python program, being able to write and evaluate Python expressions interactively will give you an immediate advantage. You can use the Python Interactive Console to perform a wide range of ad hoc calculations, just like you would with an interactive calculator. If you need to calculate a dilution volume or the number of tubes or microplates required to perform an experiment, you’ll find yourself popping open the Python Interactive Console to perform a quick calculation.
To start the Python Interactive Console, open a terminal program and enter the command python (or python3). If you are using Microsoft Windows, you can run PowerShell or Command Prompt as your terminal. On a Macintosh or Linux computer, the standard terminal program will do the trick. After entering the python command, the Python console will start in your terminal and offer you the >>> prompt. This is where you can enter any Python statement you want to be evaluated, even multi-line statements.
Figure 2.1 demonstrates the Python console started in Windows PowerShell. It will look the same, no matter which terminal program or operating system you use. To exit the console, enter the quit() or ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access