Python and Keyword

Example

If both statements are True, the return will be:

x = (5 > 3 and 5 < 10)
print(x)

Run Instance

Definition and Usage

The and keyword is a logical operator.

Logical operators are used to combine conditional statements.

If both statements return True, the return value will be True, otherwise False.

More Examples

Example

Using the and keyword in if statements:

if 5 > 3 and 5 < 10:
  print("Both statements are True")
else:
  print("At least one of the statements is False")

Run Instance

Related Pages

Keywords or and not It is also a logical operator.

In our Python Operator Tutorial Learn more about operators in Chinese.