Python AND Operator
Last Updated : 17 Mar 2025
The 'and' operator is a logical operator in Python used to combine two or more conditions. This operation returns a Boolean Value - True if all conditions are true; otherwise, it returns False.
The syntax of Python 'and' operator is as follows:
Syntax:
If both the conditions, condition_1 and condition_2 are True, then this operation returns True. But if either one of the condition is False, or both are False, the result will be False. Hence, we can say that all conditions must be true, for the 'and' operation to return True.
Flowchart of AND Operation
We will now look at the following flowchart that visually represents the working of the 'and' operator in Python.

Step-by-Step Explanation of the Flowchart:
Step 1: Evaluate the expression X and Y (overall logical condition)
Step 2: Check the value of X (first operand)
- If X == False, the expression X and Yimmediately returns False, and Y would not be evaluated (short circuit behaviour).
- If X == True, Python checks for second operand Y.
Step 3: Check the value of Y (second operand)
- If Y == True, the result is True.
- If Y == False, the result is False.
Truth Table of Python AND Operator
| Expression 1 | Expression 2 | Result |
|---|---|---|
| False | False | False |
| False | True | False |
| True | False | False |
| True | True | True |
Python AND Operator with Boolean Expressions
Python 'and' operator is commonly utilized to combine multiple Boolean expressions (expressions that evaluates to either True or False). When we use the 'and' operator, the entire expressions returns True only when all expressions evaluate to True. It returns False if at least one or all expressions are False.
Here is an example showing the use of Python 'and' operator with Boolean Expressions:
Example
Output:
Boolean Expression 1: True Boolean Expression 2: True Boolean Expression 3: False True and True = True True and False = False
Explanation:
In the above example, we are given few Boolean expressions. We have used the 'and' operator in order to combine multiple expressions. For the first operation, both values are True, therefore, the resultant is also True. However, in the second case, we have one False value, which makes our result False.
Python AND Operator in if
We can use the 'and' operator in the if statement in order to check multiple conditions at once. The whole if condition evaluates to True if and only if all conditions joined by and are True.
Let us take a look at the following example.
Example
Output:
8 is NOT divisible by 6. 18 is divisible by 6. 33 is NOT divisible by 6. 72 is divisible by 6.
Explanation:
In this example, we have defined a function as is_divisible_by_six() that takes an argument as num. Inside this function, we have used the 'and' operator in the if statement to check if the passed argument is divisible by 2 and 3. We have then called the check_number() to check different numbers such as 8, 18, 33, and 72.
As a result, if both the conditions specified in the if statement are True, the print() function inside the if block is executed; otherwise the else block is executed.
Python AND Operator - Short Circuiting
In Python, Short-circuiting refers to the stoppage of the execution of Boolean operation if the truth value of the expression has already been determined.
In case of the 'and' operator, if the first operand or Boolean expression is False, Python will not check of the second one, as the entire expression becomes False already.
We will now take a look at the following example:
Example
Output:
Inside the 'False' function Case 1: False Inside the 'False' function Case 2: False Inside the 'True' function Inside the 'False' function Case 3: False Inside the 'True' function Inside the 'True' function Case 4: True
Explanation:
Here, we defined two functions as true() and false(). Inside these functions, we have returned the Boolean values - True and False. We have then used the 'and' operator in order to combine these functions during calls.
As a result, we can see how Python short-circuiting when the first operand is False.
Conclusion
In this tutorial, we learned about Python 'and' operator with various examples. We discussed how to use the 'and' operator with Boolean expressions and in the if statements. At last, we discussed, how short circuiting affects to flow of execution in Python 'and' operator.
Python AND Operator FAQs
1. What does the 'and' operator do in Python?
The 'and' operator is a logical operator that returns True only if both operands are True. Otherwise, it returns False.
Example
Output:
True False
2. Can the 'and' operator be used with non-Boolean values?
Yes. Python returns the first falsy value, or the last operand if all are truthy.
Example
Output:
0 10
3. Does 'and' support short-circuiting?
Yes. Python stops evaluating as soon as it finds the result.
Example
Output:
Else Block
4. How is and used in if statements?
To check multiple conditions:
Example
Output:
You can drive
5. What is the difference between and and & in Python?
- and: Logical operator (used for booleans)
- &: Bitwise operator (used for integers/bit-level operations)
Example
Output:
False 1
Next TopicPython OR Operator