VOOZH about

URL: https://www.geeksforgeeks.org/python/check-for-true-or-false-in-python/

⇱ Check for True or False in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check for True or False in Python

Last Updated : 23 Jul, 2025

Python has built-in data types True and False. These boolean values are used to represent truth and false in logical operations, conditional statements, and expressions.

In this article, we will see how we can check the value of an expression in Python.

Common Ways to Check for True or False

Python provides various ways to check if an expression is evaluated as True or False. Let us see them one by one:

Using bool() Function

The bool() function is an in-build Python function that returns the Boolean value of an expression.


Using Comparison Operators

We can use Comparison operator to check if an expression evaluates to True or False. == and != Operator can be used with if condition or while statement to evaluate an expression.


Output
True
False


Using Logical Operators

Logical Operators (and, or, not) allow combining multiple conditions.


Output
False
True
False


Using Identity Operators

Identity Operator such as 'is' and 'is not' Operator can be used to check if two variables reference the same object in memory. They are particularly useful when you need to check for object identity rather than equality.


Output
True
False


Comment
Article Tags:
Article Tags: