0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Codewars 8 kyu Exclusive "or" (xor) Logical Operator

Posted at

Codewars 8 kyu Exclusive "or" (xor) Logical Operator

Task

In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns true if exactly one of the two expressions are true, false otherwise.

Verbalization

ひとつひとつ条件付けする

#Code

def xor(a,b):
    if a == False and b == False:
        return False
    if a == False and b == True:
        return True
    if a == True and b == False:
        return True
    if a == True and b == True:
        return False

Other example

def xor(a,b):
    return a != b
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?