python의 set 주의점
class set(object) | set() -> new empty set object | set(iterable) -> new set object | | Build an unordered collection of unique elements. python의 set이란 집합을 의미한다. 집합 자료형에는 두 가지 특징이 있는데, 하나는 순서가 없다는 것이고, 하나는 원소가 중복될 수 없다는 것이다. 순서가 없다는 것은 무작위성을 가진다는 것을 의미한다. asdf = set('asdf') qwer = set('qwer') print(list(asdf), list(qwer)) ['s', 'd', 'f', 'a'] ['w', 'e', 'r', 'q'] ['a', 'f', 's', 'd'] ['e', 'w', ..
2021. 9. 5.
NAND NOR
NAND 게이트의 조합만으로 모든 게이트를 만들 수 있다. 아래는 NAND 게이트의 퍼셉트론만으로 모든 게이트를 구현한 python 코드이다. def NAND(x1, x2): a0 = -0.5 * (x1 + x2) + 0.7 if a0 > 0: return 1 else: return 0 def NOT(x): return NAND(x, x) def AND(x1, x2): return NOT(NAND(x1, x2)) def OR(x1, x2): return NAND(NOT(x1), NOT(x2)) def NOR(x1, x2): return NOT(OR(x1, x2)) def XOR(x1, x2): return AND(NAND(x1, x2), OR(x1, x2)) def XNOR(x1, x2): return ..
2021. 8. 9.