The basic format of if statement in python

王林
Release: 2020-06-15 09:50:44
Original
22503 people have browsed it

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:
    执行语句……
Copy after login

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), < (less than), == (equal to), >= (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……
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template