Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Boolean Algebra by mag.py
OPERATION_NAMES = ("conjunction", "disjunction", "implication", "exclusive", "equivalence")
def boolean(x, y, operation):
if operation == 'conjunction':
return x and y
elif operation == 'disjunction':
return x or y
elif operation == 'implication':
return y if x else True
elif operation == 'exclusive':
return x ^ y
elif operation == 'equivalence':
return x == y
else:
raise KeyError("{} is not a valid operation.".format(operation))
April 22, 2016
Comments: