1,python Process Control single condition basic statement
2,python process Flow Multi-condition control statement
1,python Process Control single condition basic statement
If judgment condition: Execute statement ... else: EXECUTE statement ....
Judge the condition to be true, that is, execute the statement, otherwise execute the statement in the else. The variable is not NULL or not 0 or none is true.
Example:
#! /usr/bin/env python#-*-coding:utf-8-*-n = input (' Please input number: ') if n > 0: print ' n is positive ' else: print ' n is negative '
2,python process Flow Multi-condition control statement
If judgment condition 1: EXECUTE statement 1......elif judgment Condition 2: EXECUTE statement 2......elif judgment Condition 3: Execute statement 3......else: EXECUTE statement 4 ...
Example:
#!/usr/bin/env pythonscore = Int (raw_input (' Please INPU score: ')) if score >=: print ' A ' elif score >=: print ' B ' elif score >=60: print ' C ' elif score <60: print ' D '
Python Process Control (conditional statements)