python acquaintance - environmental structures, variables, conditional, loop

1.python environment to build:

(1) Installation Anaconda, optionally C non-mounting plate;


Note: all check;

 

(2) Installation Pycharm

The default installation, the installation process also are checked;

 

(3) break Pycharm

https://www.jianshu.com/p/b749797f48b2

 

2.python Language Overview

(1) high-level language:

  Development of high efficiency, low efficiency, java similar, but slightly lower than the java implementation efficiency;

  

(2) python compiler theory

--- through the python interpreter python - bytecode - c by a compiler - machine code

  Python underlying are implemented in C;

       Can be used for page background, etc. can be, and portability, multi-platform use;

 

 (3) python Run

The window, cmd window:: embodiment 1 python xx.py

Method 2: Double-click the executable file python.exe, open the code file, run;

Note: Although the code can be run in different file formats in the python interpreter;

           However, if it is imported, it must be suffix .py file;

 

3. Variables

(1) naming rules:

Letters, underscores, numbers;

You can not start with a number;

And keywords can not be repeated;

And internal functions can not be repeated, otherwise the system will function redefined;

 

(2) Example:

1 day_num = 5
2 name = "sky"
3 print(day_num)
4 print(name)

Results: 5

           sky

 

4. Conditional statements

(1) if the syntax

if the condition is determined:

    Block 1

    Block 2

elif Analyzing conditions:

    Block

else

      Block

 

(2) if nested

if the condition is determined:

    if the condition is determined:

        Block

    else

         pass

else

     Block

 

Note: if the block is not executed if any, must be written pass, can not be null, and that C language is different;

           A plurality of code blocks with the same must be retracted, normal cells is 4, otherwise only the first block of code;

           Nested if nested C-like, can be used normally;

 

(3) Example

1 num1 = 5
2 num2 = 3
3 
4 if num1 == num2:
5     print("abc")
6     print("xyz")
7 else
8     print("opq")

 

    5.while statement

(1) sentence model

while the judge sentences

  Block

 

(2) statement uses

while while similar statements and the C language:

If the judgment statement established, the code block is executed;

When the judgment statement does not hold, exit the loop;

 

 

 

 

 

 

 



 

Guess you like

Origin www.cnblogs.com/xiaoyudian/p/11992612.html