Home  >  Article  >  Backend Development  >  The basic format of if statement in python

The basic format of if statement in python

王林
王林Original
2020-06-15 09:50:4422473browse

The basic format of if statement in python

The if statement in Python is used to control the execution of the program.

The basic format of the if statement in python:

if 判断条件:
    执行语句……
else:
    执行语句……

When the "judgment condition" is true (non-zero), the following statements will be executed, and the execution content can be multiple lines, distinguished by indentation represents the same range.

else is an optional statement. When you need to execute content when the condition is not true, you can execute related statements.

The judgment conditions of the if statement can be expressed by > (greater than), 2342cb0436bd835a7369fdb5de0d7456= (greater than or equal to), <= (less than or equal to). .

When the judgment condition is multiple values, you can use the following form:

if 判断条件1:
    执行语句1……
elif 判断条件2:
    执行语句2……
elif 判断条件3:
    执行语句3……
else:
    执行语句4……

Recommended tutorial: python tutorial

The above is the detailed content of The basic format of if statement in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn