Python conditional statements
Translation results:
Python conditional statements are code blocks that are executed based on the execution results (True or False) of one or more statements.
Python conditional statementssyntax
The Python programming language specifies that any non-zero and non-null value is true, and 0 or null is false.
Python conditional statementsexample
#!/usr/bin/python# -*- coding: UTF-8 -*- #Example 1: Basic usage of if flag = Falsename = 'luren'if name == 'python': # Determine whether the variable is 'python' flag = True #Set the flag to true when the condition is true Print 'welcome boss' # and output the welcome message else: print name # Output the variable name when the condition is not true