Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import random
  2. def genSign(lenghtofsignal=20):
  3. for x in range(lenghtofsignal):
  4. x= random.randint(0,1)
  5. print(x, end='' )
  6. print('')
  7.  
  8. def andSign(A1, A2):
  9. i=0
  10. andS = ' '
  11. for element in A1:
  12. if A1 == A2:
  13. andS = andS + A1
  14. i=i+1
  15. else:
  16. andS = andS + "0"
  17. i=i+1
  18.  
  19. def notSign(Sign):
  20. notS=''
  21. for noBit in range(len(Sign)):
  22. if Sign[noBit] == '0':
  23. notS += '1'
  24. else: notS += '0'
  25. return notS
  26.  
  27. #def Q121(w, t = 4):
  28.  
  29. A1 = genSign()
  30. A2 = genSign()
  31. B = genSign()
  32. A1A2 = andSign(A1, A2)
  33. notA1A2 = notSign(A1, A2)
  34. W = andSign(B, notA1A2)
  35. Q = Q121(w, t)
  36.  
  37. print ("A1 > " + A1)
  38. print ("A2 > " + A2)
  39. print ("A1A2 >"+A1A2)
  40. print ("!A1A2 >"+notA1A2)
  41. print ("B > " + B)
  42. print ("W > " + W)
  43. print ("Q > " + Q)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement