----------------------------IV----------------------------
Print function
---------------------------------------------------
Print----Encoding-----Code encoding consistent with file encoding
----------------------------------------------------
PY2: Chinese will error----default ASCII
PY3: No error-----default UTF-8
-----------ASCII code (255) does not include Chinese-----------
-----------UTF-8 (all characters)-------------------
-----------gbk--(Chinese)-----------------------
Py2 >>> convert--------#-*-encoding:utf-8-*-------------------
Py2 >>> convert--------#-*-encoding:gbk-*-------------------
Assigning values to variables
-----------
Assigning values to variables
-----------
Variable name <--msg = '--string----------------an equals sign
2--Digital type
2.34---> Floating point
-----Easy to use multiple times
-----can modify the content to point to
------------------------
Variable name naming rules:
-------------------------
Can only be letters, numbers, underscores
Numbers can not start
Cannot be a keyword inside python
Age=18
Age1=age
Age2=age1
age1=666
Print ("Age,age1,age2")
Data type
-------------------------------------------------------------
------Integer Type-----age=18
------String Type----"Apple"
------Boolean Type-----true--false
type of Operation
---------------------------------------------------------------
------Arithmetic Operations
Numbers: result=1+1-----Subtraction-----
String: result= "abc" *8
result= "abc" + "ACD"
------comparison operation
-Conditional statements
--------------------------------------------------------------
If [condition]:
Age = = Input (")
If [condition]:
Print (")
Else
Print (")
elif [conditions]:
Print (")
Else
Print (")
-------conditions from the top down---------
-------------four spaces to indicate indentation---------
---------------------------------------
Input ()---->>> can only get string
-------------------------------------
Looping statements
-----------------------------------------
---
While [condition]:
Print (1)
While True:----------------dead Loop
Print (2)
Print (3)
Print (4)
Print (5)
------------------------
While:
Break---Jump out of the loop
------------------------
------------------------------
While
Continue-----Jump out of this cycle
-----------------------------------
Python basic syntax