About 50 results
Open links in new tab
  1. What is the practical application of bool () in Python?

    Jul 21, 2014 · To understand what bool() does we need to first understand the concept of a boolean. A boolean variable is represented by either a 0 or 1 in binary in most programming languages.

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

    4 Yes, there is a bool data type (which inherits from int and has only two values: True and False). But also Python has the boolean-able concept for every object, which is used when function bool([x]) is …

  3. Beginner question: returning a boolean value from a function in Python

    Nov 12, 2010 · I'm trying to get this rock paper scissors game to either return a Boolean value, as in set player_wins to True or False, depending on if the player wins, or to refactor this code entirely so that it

  4. What does -> mean in Python function definitions?

    Jan 17, 2013 · In Python 3.5 though, PEP 484 -- Type Hints attaches a single meaning to this: -> is used to indicate the type that the function returns. It also seems like this will be enforced in future versions …

  5. How do I get the opposite (negation) of a Boolean in Python?

    Do not use the bitwise invert operator ~ on booleans One might be tempted to use the bitwise invert operator ~ or the equivalent operator function operator.inv (or one of the other 3 aliases there). But …

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

    @AnatolyAlekseev, argparse developers are fully aware that some users try to handle strings like "True" or "False" as booleans, but have rejected proposals to redefine the basic Python bool function. …

  7. bool value of a list in Python - Stack Overflow

    Mar 24, 2012 · Python can see that you're evaluating an if statement and it calls bool() itself. If you really then a boolean value (for example, as output) then bool(my_list) is fine of course.

  8. Converting from a string to boolean in Python - Stack Overflow

    How do I convert a string into a boolean in Python? This attempt returns True: >>> bool ("False") True

  9. boolean - 'True' and 'False' in Python - Stack Overflow

    From 6.11. Boolean operations: In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: False, None, numeric …

  10. Python syntax -> bool - Stack Overflow

    Nov 13, 2021 · I have a lot of Matlab experience but trying to learn Python syntax from Leetcode challenges. What does the -> bool mean in the method below? def isPalindrome(self, head: …