1, conditional judgment: Boolean expression: 0 or 1, not 0 is considered to be true
2, relational expression: >,<,==,!=,>+,<=
3, logical expression: and Or not
4,in,not in
True, False is a python built-in variable
Syntax structure:
If condition:
print ' True '
Else
print ' False '
Boolean expression:
EG1:
If True:
print ' OK '
Else
print ' No '
EG2:
If 0:
print ' OK '
Else
print ' No
EG3:
If 13:
print ' OK '
Else
print ' No
EG4:
If ' Baidu ':
print ' OK '
Else
print ' No '
Relational Expressions:
10>9------True-----> Boolean expression 1 (True)
10<9------False----> Boolean expression 0 (false)
EG1:
Record=int (raw_input (' plz input your record: '))
If record>=90:-------------relational Expressions: relational operators
print ' good! '
Else
print ' bad!
EG2:
Sex=raw_input (' plz input your sex: ')
If sex== ' male ':-------------relationship expression: relational operator
print ' Man '
Else
print ' Woman '
Logical expressions:------------Learn to construct more complex expressions with logical expressions
And, or, binocular operators
Not single-mesh operator
EG1:
Sex=raw_input (' plz input your sex: ')
If not sex== ' male ':-------relational expression-----Logical expression------Boolean expression
print ' Man '
Else
print ' Woman '
EG2:
Sex=raw_input (' plz input your sex: ')
If sex== ' male ' or sex== ' m ' or sex== ' man ' or sex== ' man ':----or one is true;
print ' Man '
Else
print ' Woman '
12th. If branch statement expression constructs