1 >>>python Foundation

Source: Internet
Author: User
Tags arithmetic arithmetic operators logical operators true true

The content of this section
    1. Run the first program
    2. Environment variables
    3. Comments
    4. Concatenation of strings
    5. Operator
1 running the first program Hello world

For a long time, the programming community has thought that touching a new language is if it is used first to write a message "Hello world!" on a screen program that will bring you good luck.

Find Python file path replication

Computers >>> Properties >>> advanced system settings >>> environment variables >>> System variables >>>path>>> variable values >>> First enter the English semicolon;>>> paste >>> always click OK

Computer start >>> Search cmd click inside after CD c \   Open C drive D is the D CD command to open the character directory CD.   Returns the previous level of the directory \. Return to upper-level directory

dir command to view the current file directory list

Enter the cmd input python into python

Just one line of code:

Print ("Hello World"!)

2 Environment variables

A variable is a container for storing data (used to store data for descriptive data).

Rules:

1 descriptive

2 Variable name with _ underline, number, letter composition cannot use special symbol (#? > < $ *! )

3 cannot use Chinese as a variable name

4 cannot start with a number (including spaces)

5 reserved characters cannot be used such as print printing

Constants: Constant amount of π= 3.141592653 .......

In Python, all variables are mutable.

3 Notes

is to add a description in the program just like the first high school in classical Chinese the annotation nature is the same

Single line comment start with #

Multiple lines with three single or three double quotation marks (beginning and ending plus)

wk= "I love Beijing Tian ' an gate, Tiananmen Square sun Rise" "" "Print (wk) print (wk) print (wk) print (wk) print (wk)" "" #print (wk) #print (wk) #print (wk) print (wk) Print (wk) #想显示中文  text encoding using  UTF-8 "" "#井号后面的   or   beginning with three double quotes ending with three double quotes can be comment" ""

  

4 Concatenation of strings

>>>print (' abc ', ' abc ')

There are spaces in the middle of the result

>>>python (' abc ' + ' abc ')

Results ABCABC attached to the

5 operator

Arithmetic operators

+-*/subtraction

Comparison operators

> < greater than or less than

>= <= greater than or equal to less than equals

= = = Equal (the value of two variables is equal) not equal

Assignment operators

num + = 1 is equivalent to num = num+1

As with arithmetic operations, etc.

logical operators

Not does not

And and

OR OR

Short Circuit principle

For and the first condition is false, the result is false. The second condition is not counted.

For or if the first one is true, then the result is true. The second condition is not counted.

Gca

Not is true or False and not true

#两个not抵消 true for or is true result is true after not counting

Boolean value: True True false false

1 >>>python Foundation

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.