1. Code structure
1) Notes
Single-line Comment: #
Multiline Comment: "" "" "" "
"""
a=11111
Print (a)
"""
2) Basic Data type
Boolean:true and False (Python-case-sensitive Boolean type)
int: integer type (python does not differentiate short,long,int uniformly using int to identify)
STR: string (single quotes, and double quotes to indicate, Python does not make a distinction)
3) Variable Assignment
a=1111111; (variable assignment, define variable without specifying type, type based on function type) Example:print (type (a)) output "Class:int"
x,y=1,2: Multivariate assignment (representing x=1,y=2) if the value of the variable that interacts with two (y,x=1,2 or x,y=2,1)
4) Object Comparison
= = Comparison value itself: example:x,y=1,1 print (x==y)
ID () comparison is memory address example (print (ID (x) =id (y)))
2. Quick Start
Print ("name") #输出一个str
Print ("name", "John Doe") #输出多个元素的值
Print ("age=" +23) #编译出错 because str and int cannot be directly stitched together (note)
Name=input ("Please enter name"); print (name) #input是接受控制台输入的参数
3, for the generated type
l1=[1,2,3,4,5]
L2=[ele+3 for ele in L1 if ele%2] # generates a new collection of element +3 divisible by 2
Python basic syntax