About 148,000 results
Open links in new tab
  1. How do I use a Boolean in Python? - Stack Overflow

    Does Python actually contain a Boolean value? I know that you can do: checker = 1 if checker: #dostuff But I'm quite pedantic and enjoy seeing booleans in Java. For instance: Boolean …

  2. Evaluate boolean environment variable in Python - Stack Overflow

    Jul 27, 2020 · This will return True for any value of MY_ENV_VAR because the boolean value of any string is True in Python. Hence, also values like False, false, 0, etc. will end up as True.

  3. Converting "true" (JSON) to Python equivalent "True"

    Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'false' is not defined If I am not mistaken, I think this is because the boolean value in the JSON …

  4. python - Parsing boolean values with argparse - Stack Overflow

    I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example: my_program --my_boolean_flag False However, the following test …

  5. Syntax for an If statement using a boolean - Stack Overflow

    I just recently joined the python3 HypeTrain. However I just wondered how you can use an if statement onto a boolean. Example: RandomBool = True # and now how can I check this in …

  6. python - Is it safe to replace '==' with 'is' to compare Boolean …

    There are cases where you need to compare booleans, for example when the boolean values are unknown at the compare-time. This need can easily emerge when you interpret the booleans …

  7. python - How do I create a numpy array of all True or all False ...

    Jan 16, 2014 · Explanation: numpy creates arrays of all ones or all zeros very easily: e.g. numpy.ones((2, 2)) or numpy.zeros((2, 2)) Since True and False are represented in Python as …

  8. python - How do "and" and "or" act with non-boolean values?

    Oct 30, 2017 · 8 and and or perform boolean logic, but they return one of the actual values when they are comparing. When using and, values are evaluated in a boolean context from left to …

  9. How can I map True/False to 1/0 in a Pandas DataFrame?

    I have a column in python pandas DataFrame that has boolean True/False values, but for further calculations I need 1/0 representation. Is there a quick pandas/numpy way to do that?

  10. python - What is Truthy and Falsy? How is it different from True …

    9 Python determines the truthiness by applying bool() to the type, which returns True or False which is used in an expression like if or while. Here is an example for a custom class Vector2d …