+ - * /
// to be divisible by ( Seeking quotient )
% Take the remainder
** Index , Power operation
() You can change the priority
⽐ The result of the comparison operator is bool type , namely True, Or is it False.
== Judge whether it is equal , Equality is True. Inequality is False
!= Judge whether it is not equal , Inequality is True, equal False
><>=<=
Logical operators can connect multiple expressions , The common result of the two expressions determines that the final result is True, still False.
and Logic and , Both conditions of connection must be True, The result is
True, ⼀ False is false
If the first ⼀ The first condition is False, Will not judge the ⼆ Conditions
or Logic or , Both conditions of the connection are False, The result is
False, ⼀ It's true
If the first ⼀ The first condition is True, The first ⼆ One condition will no longer be judged
not Logic ⾮, Take the opposite , Turned out to be True, Turn into False, Turned out to be
False, Turn into True
if Judge the condition :
The judgment condition is True, Can hold ⾏ Code for
The judgment condition is True, Can hold ⾏ Code for
...
Code written in the top pane , For and on behalf of if Judgment doesn't matter
stay python Chinese envoy ⽤ Indent , Instead of code hierarchy , stay if sentence
Within the indent of , Belong to if Code block of statement ( many ⾏ The code means )
if Judge the condition :
The judgment condition is True, Can hold ⾏ Code for
The judgment condition is True, Can hold ⾏ Code for
else:
The judgment condition is False, Can hold ⾏ Code for
The judgment condition is False, Can hold ⾏ Code for
if Judge the condition 1:
Judge the condition 1 become ⽴, Of board ⾏ Code for
elif Judge the condition 2:
Judge the condition 1 no ⽴, Judge the condition 2 become ⽴, Can hold ⾏ Code for
else:
Judge the condition 1 And judging conditions 2 Not even ⽴, Of board ⾏ Code for
Variable = expression 1 if Judge the condition else expression 2
while Judge the condition :
Judgment condition ⽴, Of board ⾏ Code for
Judgment condition ⽴, Of board ⾏ Code for
for Variable in character string :
Code
Python Look at the scope of the code by indentation .