First, quotation marks and comments:
1. In Python, single quotation marks ("") and double quotation marks ("") are not distinguished, and both single and double quotation marks can be used to identify a string.
Print ("Hello") rint (' Hello ')
2, single quotes and what u that quotation marks can be nested with each other, but not cross-use.
3, #表示单条注释; Multiple lines of comments are expressed in quotation marks.
Second, the circulation
1, if loop, python through the IF statement to achieve branch judgment, Syntax: If......else ...
A=0b=1if a>b: print (' A relatively large ') Else: print (' B larger ')
Note: Python uses indentation to determine the body of the statement;
The IF statement uses the = = operator to determine equality, and by the! = operator to indicate that you do not want to wait;
The IF statement can be judged by a Boolean type:
A=trueif A: print (' A is true ') Else: print (' A was not true ') output A is true
If statement multiple conditional judgment:
If score >=90: print (' excellent ') Elif score >=75: print (' good ') elif score >=60: print (' Pass ') Else: print (' fail ')
2. For loop
For I in Range: print (i)
Note: The range (Start,end[,step]) range () function loops from zero by default, start indicates the start position, end indicates the ending position, step identifies the step of each cycle
3. While loop
While count<10: print (' hello,world! ') Count=count+1else: print (' Bye. ‘)
Break, exit the loop, break can only be used inside the loop
While count<10: print (' hello,world! ') count=count+1 if count==5: break
The use of continue, the role of continue is to exit this cycle
While count<10: print (' hello,world! ') count=count+1 if count==5: continue
、
Python Basic Learning Note one