Chapter One Introduction to Python

Source: Internet
Author: User
Tags windows x86

1th programming and programming language 1.1 what is programming

In the literal sense, programming is "writing programs". So:

Who's going to write it? Programmers

How to write? -Write using a programming language, as required.

What is a program? -The program refers to static data that is placed on the disk, which can be code, files, and so on.

Programming: Programmers use a programming language to write code based on requirements.

Before the program is not run, is placed on the disk static data, ordinary files, only when the program is running, the character content of the program corresponding to the programming language syntax, in order to let the computer understand and go to work execution, this makes sense.

1.2 What is a programming language

Programming language: A computer can read and understand code

The code that we write out of the code needs to be understood by the computer to let the computer know what we want it to do.

Programming language is the medium of human communication between computer and programmer.

1.3 Purpose of the programming

The purpose of programming: To command the computer to work for the human.

1.4 Programming language Classification

The computer actually knows only binary is 010101 ..., writing and understanding is very difficult, so there are programming languages, programming languages are divided into: machine language, assembly language, high-level language.

L Machine language: Directly using binary code to program, directly manipulate the hardware.

L assembly Language: The use of shorthand English identifiers instead of binary programming, but also the direct operation of the hardware.

L High-level language: Use human can understand the character to write the program, must be translated into the computer can read the binary, before it can be executed. Because it must be translated to be understood by the computer, it is impossible to manipulate the hardware directly.

This translation transformation in high-level languages can be divided into: compiled and interpreted

L compile-type (need compiler, equivalent to Google Translate): such as C, fast execution, debugging trouble

L Explanatory type (interpreter required, equivalent to simultaneous interpretation): Like Python, slow execution, easy commissioning

1.5 Mainstream programming languages

You can access: Https://www.tiobe.com/tiobe-index View the currently popular programming languages.

2nd Chapter Pyhton Introduction 2.1 Python Introduction

Python is an excellent comprehensive language, the purpose is concise, elegant, powerful, in artificial intelligence, cloud computing, financial analysis, Big Data development, Web development, automation operations, testing and other directions widely used (if someone asked and PHP differences, tell him that PHP only focus on the web, Python is the 4th most popular programming language in the world because of its wide and powerful application.

Pythonpython's founder is Guido van Rossum (Guido van Rossum). During the Christmas of 1989, Guido began writing an interpreter that would explain the syntax of the Python language. The name Python, from Guido's beloved TV show Monty Python's Flying Circus. He hoped that the new language, called Python, would fit his ideals: create a language that is all-powerful, easy to learn, easy to use, and extensible, between C and Shell.

2.2 Python Version Selection

So far, there are only two versions of the popular and applied ones, namely:

Python2 and Python3, because Python3 can not be backward compatible, so many users refused to upgrade to version 3.0, but chose to use

Python2.7 this transition version. We can learn in the course of the Master 3.0 version, and then also master the differences between the two different versions.

3rd. Install Python3 and Python23.1 download package

L sign in to Python website:

https://www.python.org/

Select Downloads and Windows on the home page

L Select the version you want to download the top two are the latest version

If you are just learning python, or planning to use Pyhton for a long time, it is recommended to use 3.

Pyhton2 and Python3 are incompatible.

L above 3 is 64 bits, below 3 is 32 bit, is correspondence relation, according to your PC's operating system to choose.

We recommend using executable files:

Windows x86-64 Executable Installer

L PYTHON2.7.13 installation Package selection: Windows x86-64 MSI Installer

3.2 Installing Python3.6.2

Double-click Python-3.6.2-amd64 to enter the installation page

Select Custom installation and tick add Python 3.6 PATH, which will help you install the environment variables by default.

L Default Select All, NEXT

This step to note: The path is recommended directly using the Python directory under C, then click Install.

• Successful Installation

Verify:

L Enter Python-v to display the Python counterpart version.

L input pip-v, display pip corresponding version

PIP is the management tool for Python third-party packages that you can use to install, delete, and manage local third-party packages.

l See how PIP Works

3.3 Installing Python2.7.13

L Double-click Python-2.7.13.amd64 to enter the installation interface, the default selection of the first for all users to install;

L Friendly Help us choose to install under the C drive ~

L Make sure to hook this up: Add python.ext to Path, then next to install

• Successful Installation

4th. Switching between Python versions

Now that we have installed the Pyhton3 and installed the Python2, we can switch to the Python version on the same computer.

In the previously opened CMD window, enter the view Python and PIP versions or the previously installed Python3.

L Close this cmd window and re-open one:

Discovery has become python2, this is because later installed Python2 also chose to add environment variables, newly added to the front, covering the previous python3.

L Input pyhton3-v and pip3-v

Can find PIP3, but can't find python3, if solve?

4.1 Viewing environment Variables for Python3

L Right-click My Computer, properties, advanced system settings, select environment variables

The above is the user variable, the following is the system variable, we modify the system variable

L Find the path and select "Edit"

L We found Python2 before Python3, so the default is to find Python2.

C:\Python27\; C:\Python27\Scripts; C:\Python36\Scripts\; C:\Python36\, ......

4.2 Troubleshooting Unable to switch to Pyhton3

L Enter C:\Python36, copy a Python.exe

Paste into the current directory, and then rename to: Python3.exe, note that there is also a python.ext in the directory, or PIP3 will not be found.

L then view: Python3 is normal.

4.3 Let Python3 be the default execution

L Copy an python.ext to the Python2 directory, rename the Python2.exe, and go to the script directory to make sure there are Pip.exe and Pip2.exe.

L Modify the environment variables so that the PYTHON3 environment variables are in front.

Chapter One Introduction to Python

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.