About 176,000 results
Open links in new tab
  1. Python Booleans - W3Schools

    Booleans represent one of two values: True or False. In programming you often need to know if an expression is True or False. You can evaluate any expression in Python, and get one of two answers, True or False. When you compare two values, the expression is evaluated and Python returns the Boolean answer:

  2. Python Boolean - GeeksforGeeks

    Dec 5, 2024 · In Python, integers and floats can be used as Boolean values with the bool() function. Any number with a value of zero (0, 0.0) is considered False while any non-zero number (positive or negative) is considered True.

  3. Python Booleans: Use Truth Values in Your Code – Real Python

    In this tutorial, you'll learn about the built-in Python Boolean data type, which is used to represent the truth value of an expression. You'll see how to use Booleans to compare values, check for identity and membership, and control the flow of your programs with conditionals.

  4. Booleans in Python

    Learn about Python booleans, their declaration, boolean values of data types using bool() function & operations that give boolean values.

  5. Python Boolean and Conditional Programming: if.. else

    Jun 8, 2022 · In Python, we use booleans in combination with conditional statements to control the flow of a program: >>> door_is_locked = True >>> if door_is_locked: ... print("Mum, open the door!") ...

  6. Python Booleans: A Complete Guide with Examples

    Dec 10, 2024 · A Boolean is a data type that can hold one of two possible values: True: Represents a condition that is correct or satisfied. False: Represents a condition that is incorrect or not satisfied. Python uses Booleans extensively in conditional statements and logical operations. Example of Boolean Values: is_python_easy = True is_java_hard = False

  7. How do I use a Boolean in Python? - Stack Overflow

    Mar 16, 2018 · Python booleans are integers. True and False are references to extended int objects with overriden __str__ and __repr__. Python booleans are not integers; 1 is not True, but 1 == True. @BallpointBen: they are integers in the common sense of being instances of the int type, as shown by isinstance(True, int).

  8. Understanding Boolean Logic in Python 3 - GeeksforGeeks

    Jul 7, 2022 · There are Three Logical operators: and, or, not. True if operand is false. A Truth Table is a small table that allows us, to give the results for the logical operators. and Table : It takes two operands. or Table : It takes two operands. not Table : It takes only one operand. Example 1 : Checking whether a list is empty or not.

  9. Python Boolean - Python Tutorial

    Python boolean data type has two values: True and False. Use the bool() function to test if a value is True or False. Falsy values evaluate to False whereas truthy values evaluate to True. Flasy values are the number zero, an empty string, False, None, an empty list [], an empty tuple (), and an empty dictionary {}.

  10. Understanding Python Booleans - W3docs

    In Python, a boolean can be created by using the bool keyword followed by a value. For example: You can also create a boolean by using comparison operators, such as ==, !=, <, >, <=, and >=. For example: print (result) In this example, result will be True because 5 is indeed less than 10.

  11. Some results have been removed
Refresh