In this article we have some knowledge of conditional statements, and the Python conditional statement determines the code block that executes by executing the result of one or more statements (true or false). The Python program language specifies any non-0 and non-null (NULL) values of true,0 or NULL to FALSE.
pythonif StatementsFor the execution of control procedures.
The IF statement in PythonThe scope of the application is quite broad, some friends who have just come into contact with Python do not understand the use of this conditional statement, then I will introduce the P
usage of LI statements in YthonAnd about its basic knowledge.
First its flowchart is as follows:
It can also be understood as:
If you want to judge the condition: when the condition is established, the thing to do
1. For example:
age = print "------If judgment starts------" if age>=18: print "I'm a grown-up." print "------If judgment ends------"
The results of the above operation:
--if Judgment begins--
I'm already a grown-up.
--if Judgment End--
2. For example:
age = print "------If judgment starts------" if age>=18: print "I'm a grown-up." print "------If judgment ends------"
The results of the above operation:
--if Judgment begins--
--if Judgment End--
The above 2 examples above are only the values of the variables are not the same, the results are different; be able to see the action of the IF Judgment statement: The code is executed when certain conditions are met, otherwise the code will not be executed.
In this article, we understand the python in the IF condition statement, do not understand the words can actually try to do, after all, hands-on practice is the best way to verify the learning. Finally, I hope that this article will give you a little help in learning about Python.
For more information, please visit the PHP Chinese Web Python tutorial section.