What is the IF condition statement in Python? Instance parsing conditional statements

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.