The content of this section
- Run the first program
- Environment variables
- Comments
- Concatenation of strings
- 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