What are the python if tests and grammar rules
This article mainly explains "what are python if tests and grammar rules". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what python if tests and grammar rules are.
I. Overview
A Python conditional statement is a block of code that determines execution by the execution result of one or more statements (True or False).
You can use the following figure to briefly understand the execution of conditional statements:
II. If statement
The general form of the if statement in Python is as follows:
If condition_1:
Statement_block_1
Elif condition_2:
Statement_block_2
Else:
Statement_block_3
If "condition_1" is True, the "statement_block_1" block statement will be executed
If "condition_1" is False, "condition_2" will be judged.
If "condition_2" is True, the "statement_block_2" block statement will be executed
If "condition_2" is False, the "statement_block_3" block statement will be executed
Note:
1. Use a colon (:) after each condition to indicate the block of statements to be executed after the condition is met.
2. Use indentation to divide sentence blocks, and sentences with the same indent number form a sentence block.
3. There is no switch-case statement in Python.
Third, the commonly used operator operator description = greater than or equal to = equal, compare whether the object is equal! = does not mean thank you for reading, the above is the "python if test and grammar rules are what" the content, after the study of this article, I believe that you have a deeper understanding of the python if test and grammar rules is what this problem, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!