Guest User

Untitled

a guest
Jan 26th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. OPERATION_NAMES = ("conjunction", "disjunction", "implication", "exclusive", "equivalence")
  2.  
  3. def boolean(x, y, operation):
  4. if operation == u"conjunction":
  5. return (x and y = 1)
  6. if operation == "disjunction":
  7. return x or y = 1
  8. if operation == "implication":
  9. return not x or y = 1
  10. if operation == "exclusive":
  11. return x ^ y = 1
  12. if opertaion == "equivalence":
  13. return not (x ^ y) = 0
  14.  
  15. if __name__ == '__main__':
  16. #These "asserts" using only for self-checking and not necessary for auto-testing
  17. assert boolean(1, 0, "conjunction") == 0, "and"
  18. assert boolean(1, 0, "disjunction") == 1, "or"
  19. assert boolean(1, 1, "implication") == 1, "material"
  20. assert boolean(0, 1, "exclusive") == 1, "xor"
  21. assert boolean(0, 1, "equivalence") == 0, "same?"
Advertisement
Add Comment
Please, Sign In to add comment