Home > Article > Backend Development > Python conditional statements
Python conditional statements are code blocks that are executed based on the execution results (True or False) of one or more statements.
You can simply understand the execution process of conditional statements through the following figure:
The Python programming language specifies that any non-0 and non-null value is true, and 0 or null is false.程Python programming IF statement is used to control the execution of the program. The basic form is:
IF judgment conditions:
execute statement ...
Lse:
execute statement ...
# coding = gb2312 flag = False name = 'luren' if name == 'python': # 判断变量否为'python' flag = True # 条件成立时设置标志为真 print 'welcome boss' # 并输出欢迎信息 else: print name # 条件不成立时输出变量名称 >>> luren # 输出结果🎜 🎜🎜🎜🎜if statement judgment Conditions can use > (greater than), = (greater than or equal to), (greater than),