Chapter II Introduction to Python

Source: Internet
Author: User
Tags sublime text

Python is a programming language widely used in the fields of bioinformatics, data analysis, and web programming. Python code is simple, elegant, easy to read, and has become a popular programming language for biologists. one of the benefits of Python is that you can write programs quickly without having to write programs after mastering a lot of programming knowledge. Python offers a variety of programming styles, including imperative programming styles, object-oriented programming styles, functional programming styles, and logical programming styles, which I will not cover in detail as these are beyond the scope of this album. In this album you will learn about Python's popular programming style-imperative programming style. Python can get started quickly, but it will take a while for most people to learn the basics of this album, and then learn other advanced books as needed.

1. Download and install

To learn Python programming, you first have to install Python on your computer, just like any other application you might have installed on your computer (for example, QQ, etc.). It can be used (for free) and run on all operating systems in the General Biology Lab (UNIX and Linux,macintosh,windows,vms, etc.). the Python application on your computer uses the Python language program (for example, the program you will write in this book), transforms it into an instruction that the computer can understand, and runs (or "executes") it.

1.1 python installation

Currently, Python is made up of two large versions, version 2.x and 3.x, and these two versions are incompatible. Since the 3.x version is becoming more and more popular, the new version 3.7 and 3.6 has changed so much that our albums

will be based on version 3.5. In addition, the programs written by Python can be run across platforms, so we will use Windows System (Windows 7) as the development platform.

1.1.1 Installing Python

First, download the python3.5 64-bit/32-bit installer from the Python website based on the number of Windows system bits (64/32), and then run the downloaded EXE installation package. Pay special attention to the Add Python 3.5 to PATH hook, then click "Install Now" to complete the installation.

1.1.2 Installation Test

After successful installation, press "Win + R" key combination, run "cmd" command to open DOS window, enter "python" in DOS window, " carriage return The following results will be executed immediately and the installation is successful.

  Appears as follows, because Windows will be based on an Path environment variable set path to find python.exe , if not found, will be an error. If you omit the tick Add Python 3.5 to PATH When you install it, manually python.exe add the path you are in to path. If you do not know how to modify the environment variables, it is recommended to run the Python installer again, be Add Python 3.5 to PATH sure to remember the hook.

1.2 Running a python program

on Windows systems, the file name extension. PY is typically associated with a Python program. This is done as part of the Python installation process, which modifies the registry settings to include this file association. you can then start this_program.py by typing This_program in the MS-DOS command window or by typing python this_program.py. Windows has a path variable that specifies the folder in which the system looks for programs, which are modified by the Python installation process to include the path to the Python application folder, typically C: \ python. If you are trying to run a Python program that is not installed in a folder known to the path variable, you can type the full pathname of the program, for example:

PY c \ windows \ Desktop \ my_program.py

Or

Python c \ windows \ Desktop \ my_program.py

2. Writing a Python program

Now that the computer has Python installed, we need to select and learn the basics of the text editor. A text editor is used to type documents, such as programs, and to save the contents of these documents to a file. Therefore, to write a Python program, you need to use a text editor. So here's the question: where is the text editor strong? The text editor recommended here consists of sublime text, notepad++, Atom.

After you have installed the text editor, enter the following code:

Print ("atagtagatagta")

Notice that print there are no spaces ahead. Then, select a directory, such as D :\bioinformatics , save the file as chapter02_01.py , you can open the Command Line window, the current directory to switch to the chapter02_01.py directory, you can run the program:

D:\bioinformatics>py chapter02_01. Pyatagtagatagta

3. Python Help documentation

If you installed Python as described earlier, the document will be installed as part of a regular Python installation (as shown). The Python standard document contains usage information and sample code for standard modules, and when you participate in programming, you will learn not only the standard reference manuals, but also resources such as books, online documents, working procedures, newsgroups, archives, periodicals and conferences. It is best to find some experienced PYTHONL programmers seeking help and advice.

Resources

Begining Python for Bioinformatics

Chapter II Introduction to Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.