Recursion
Mathematics
def no_trespassing(func): def grass(lawn): res = func(lawn) if res is None: return 'No trespassing!' return func(lawn) return grass @no_trespassing def get_of_my_lawn(on_my_lawn): if on_my_lawn is True:return 'get of my lawn'
- def no_trespassing(func):
- def grass(lawn):
- res = func(lawn)
- if res is None:
- return 'No trespassing!'
- return func(lawn)
- return grass
- @no_trespassing
- def get_of_my_lawn(on_my_lawn):
if on_my_lawn is True:return 'get of my lawn'- if on_my_lawn is True:return 'get of my lawn'
class LogicGate: """LogicGate class""" def __init__(self, yin: bool, yang: bool): """Initialize attributes""" self.yin = yin self.yang = yang def logical_and(self):return self.yin and self.yang def logical_or(self):return self.yin or self.yang def logical_xor(self):return (self.yin or self.yang) and (not self.yin or not self.yang) def logical_nand(self):return not self.logical_and() def logical_nor(self):return not self.logical_or() def logical_xnor(self): """This function test for Logical Bi-conditional (XNOR)""" return not self.logical_xor()
- class LogicGate:
- """LogicGate class"""
- def __init__(self, yin: bool, yang: bool):
- """Initialize attributes"""
- self.yin = yin
- self.yang = yang
- def logical_and(self):return self.yin and self.yang
- def logical_or(self):return self.yin or self.yang
- def logical_xor(self):return (self.yin or self.yang) and (not self.yin or not self.yang)
- def logical_nand(self):return not self.logical_and()
def logical_nor(self):"""This function tests for Joint Denial (NOR)"""return not self.logical_or()- def logical_nor(self):return not self.logical_or()
- def logical_xnor(self):
- """This function test for Logical Bi-conditional (XNOR)"""
- return not self.logical_xor()
class LogicGate: """LogicGate class""" def __init__(self, yin: bool, yang: bool): """Initialize attributes""" self.yin = yin self.yang = yang def logical_and(self):return self.yin and self.yang def logical_or(self):return self.yin or self.yang def logical_xor(self):return (self.yin or self.yang) and (not self.yin or not self.yang) def logical_nand(self):return not self.logical_and() def logical_nor(self): """This function tests for Joint Denial (NOR)""" return not self.logical_or() def logical_xnor(self): """This function test for Logical Bi-conditional (XNOR)""" return not self.logical_xor()
- class LogicGate:
- """LogicGate class"""
- def __init__(self, yin: bool, yang: bool):
- """Initialize attributes"""
- self.yin = yin
- self.yang = yang
- def logical_and(self):return self.yin and self.yang
- def logical_or(self):return self.yin or self.yang
- def logical_xor(self):return (self.yin or self.yang) and (not self.yin or not self.yang)
def logical_nand(self):"""This function test for the Negation of the Conjunction (NAND)"""return not self.logical_and()- def logical_nand(self):return not self.logical_and()
- def logical_nor(self):
- """This function tests for Joint Denial (NOR)"""
- return not self.logical_or()
- def logical_xnor(self):
- """This function test for Logical Bi-conditional (XNOR)"""
- return not self.logical_xor()
class LogicGate: """LogicGate class""" def __init__(self, yin: bool, yang: bool): """Initialize attributes""" self.yin = yin self.yang = yang def logical_and(self):return self.yin and self.yang def logical_or(self):return self.yin or self.yang def logical_xor(self):return (self.yin or self.yang) and (not self.yin or not self.yang) def logical_nand(self): """This function test for the Negation of the Conjunction (NAND)""" return not self.logical_and() def logical_nor(self): """This function tests for Joint Denial (NOR)""" return not self.logical_or() def logical_xnor(self): """This function test for Logical Bi-conditional (XNOR)""" return not self.logical_xor()
- class LogicGate:
- """LogicGate class"""
- def __init__(self, yin: bool, yang: bool):
- """Initialize attributes"""
- self.yin = yin
- self.yang = yang
- def logical_and(self):return self.yin and self.yang
- def logical_or(self):return self.yin or self.yang
def logical_xor(self):"""This function test for Exclusive Disjunction or (XOR)"""return (self.yin or self.yang) and (not self.yin or not self.yang)- def logical_xor(self):return (self.yin or self.yang) and (not self.yin or not self.yang)
- def logical_nand(self):
- """This function test for the Negation of the Conjunction (NAND)"""
- return not self.logical_and()
- def logical_nor(self):
- """This function tests for Joint Denial (NOR)"""
- return not self.logical_or()
- def logical_xnor(self):
- """This function test for Logical Bi-conditional (XNOR)"""
- return not self.logical_xor()
class LogicGate: """LogicGate class""" def __init__(self, yin: bool, yang: bool): """Initialize attributes""" self.yin = yin self.yang = yang def logical_and(self):return self.yin and self.yang def logical_or(self):return self.yin or self.yang def logical_xor(self): """This function test for Exclusive Disjunction or (XOR)""" return (self.yin or self.yang) and (not self.yin or not self.yang) def logical_nand(self): """This function test for the Negation of the Conjunction (NAND)""" return not self.logical_and() def logical_nor(self): """This function tests for Joint Denial (NOR)""" return not self.logical_or() def logical_xnor(self): """This function test for Logical Bi-conditional (XNOR)""" return not self.logical_xor()
- class LogicGate:
- """LogicGate class"""
- def __init__(self, yin: bool, yang: bool):
- """Initialize attributes"""
- self.yin = yin
- self.yang = yang
- def logical_and(self):return self.yin and self.yang
def logical_or(self):"""This function tests for Logical Disjunction (OR)"""return self.yin or self.yang- def logical_or(self):return self.yin or self.yang
- def logical_xor(self):
- """This function test for Exclusive Disjunction or (XOR)"""
- return (self.yin or self.yang) and (not self.yin or not self.yang)
- def logical_nand(self):
- """This function test for the Negation of the Conjunction (NAND)"""
- return not self.logical_and()
- def logical_nor(self):
- """This function tests for Joint Denial (NOR)"""
- return not self.logical_or()
- def logical_xnor(self):
- """This function test for Logical Bi-conditional (XNOR)"""
- return not self.logical_xor()
class LogicGate: """LogicGate class""" def __init__(self, yin: bool, yang: bool): """Initialize attributes""" self.yin = yin self.yang = yang def logical_and(self):return self.yin and self.yang def logical_or(self): """This function tests for Logical Disjunction (OR)""" return self.yin or self.yang def logical_xor(self): """This function test for Exclusive Disjunction or (XOR)""" return (self.yin or self.yang) and (not self.yin or not self.yang) def logical_nand(self): """This function test for the Negation of the Conjunction (NAND)""" return not self.logical_and() def logical_nor(self): """This function tests for Joint Denial (NOR)""" return not self.logical_or() def logical_xnor(self): """This function test for Logical Bi-conditional (XNOR)""" return not self.logical_xor()
- class LogicGate:
- """LogicGate class"""
- def __init__(self, yin: bool, yang: bool):
- """Initialize attributes"""
- self.yin = yin
- self.yang = yang
def logical_and(self):"""This function tests for Logical Conjunction (AND)"""return self.yin and self.yang- def logical_and(self):return self.yin and self.yang
- def logical_or(self):
- """This function tests for Logical Disjunction (OR)"""
- return self.yin or self.yang
- def logical_xor(self):
- """This function test for Exclusive Disjunction or (XOR)"""
- return (self.yin or self.yang) and (not self.yin or not self.yang)
- def logical_nand(self):
- """This function test for the Negation of the Conjunction (NAND)"""
- return not self.logical_and()
- def logical_nor(self):
- """This function tests for Joint Denial (NOR)"""
- return not self.logical_or()
- def logical_xnor(self):
- """This function test for Logical Bi-conditional (XNOR)"""
- return not self.logical_xor()