Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def genSign(lenghtofsignal=20):
- for x in range(lenghtofsignal):
- x= random.randint(0,1)
- print(x, end='' )
- print('')
- def andSign(A1, A2):
- i=0
- andS = ' '
- for element in A1:
- if A1 == A2:
- andS = andS + A1
- i=i+1
- else:
- andS = andS + "0"
- i=i+1
- def notSign(Sign):
- notS=''
- for noBit in range(len(Sign)):
- if Sign[noBit] == '0':
- notS += '1'
- else: notS += '0'
- return notS
- #def Q121(w, t = 4):
- A1 = genSign()
- A2 = genSign()
- B = genSign()
- A1A2 = andSign(A1, A2)
- notA1A2 = notSign(A1, A2)
- W = andSign(B, notA1A2)
- Q = Q121(w, t)
- print ("A1 > " + A1)
- print ("A2 > " + A2)
- print ("A1A2 >"+A1A2)
- print ("!A1A2 >"+notA1A2)
- print ("B > " + B)
- print ("W > " + W)
- print ("Q > " + Q)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement