class Pin: def __init__(self): self.status = Bit(False) def setStatus(self, bit): self.status.setBit(bit) return self.status def getStatus(self): return self.status.getBit()
def degenerate(self): self.normalize() ampList = self.getAmp() probList = [(i * i.conjugate()).real for i in ampList] if len(probList) != 2: try: raise ValueError except ValueError: info = get_curl_info() funName = info[0] line = info[1] interactCfg.writeErrorMsg( "ValueError: the sum of the probabilities of |0> and |1> is not 1!", funName, line) randomNumber = random.uniform(0, 1) #the order of the state of the qubit must be 0 and 1 if randomNumber - probList[0] > 0: value = 1 else: value = 0 bit = Bit(value, self.ids) qs = self.entanglement if qs != None: qs.deleteItem([self]) return bit
def __init__(self): self.status = Bit(False)
from pprint import pprint from Bit import Bit from Text import Text from Math import Math pprint("Hello world") LOGGED_IN = Bit.ONE IS_PREMIUM = Bit.TWO FULL_PROFILE = Bit.THREE setting = Bit() setting.set(LOGGED_IN) setting.set(FULL_PROFILE) setting.unset(LOGGED_IN) if setting.is_set(LOGGED_IN): pprint("Logged in") else: pprint("Logged out") if setting.is_set(IS_PREMIUM): pprint("Premium") else: pprint("Not Premium") pprint("Has Duplicate: " + str(Text.has_duplicate_char("Cody"))) pprint("Upper: " + Text.upper("Cody-&cODy"))
def formatByte(self, bits): for x in range(8 - len(bits)): bits.insert(0, Bit(False)) return bits
def rightShift(self): tempBits = [Bit(False)] for x in range(7): tempBits.append(self.bits[x]) self.bits = tempBits return self.getByte()
def leftShift(self): self.bits = self.bits[-7:] self.bits.append(Bit(False)) return self.getByte()
def makeBit(): return Bit(True)