<jupyter_start><jupyter_text>**CNOT logic**<jupyter_code>import numpy as np

# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, Aer, IBMQ, QuantumRegister, ClassicalRegister, execute, BasicAer
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *
from qiskit.providers.aer import QasmSimulator

# Loading your IBM Quantum account(s)
provider = IBMQ.load_account()
import math
%matplotlib inline
# Set up the program
a = QuantumRegister(1, name='a')
b = QuantumRegister(1, name='b')
c = QuantumRegister(1, name='c')
r1 = ClassicalRegister(1, name='r1')
r2 = ClassicalRegister(2, name='r2')
r3 = ClassicalRegister(3, name='r3')
qc = QuantumCircuit(a, b, c, r1, r2, r3)
## initialization
qc.reset(c)
qc.x(c)
qc.measure(c, r1)
qc.barrier()
qc.reset(b)
qc.reset(c)
qc.x(b)
qc.cx(b, c)
qc.measure(b, r2[0])
qc.measure(c, r2[1])
qc.barrier()
qc.reset(a)
qc.reset(b)
qc.reset(c)
qc.x(a)
qc.x(b)
qc.ccx(a, b, c)
qc.measure(a, r3[0])
qc.measure(b, r3[1])
qc.measure(c, r3[2])
backend = BasicAer.get_backend('statevector_simulator')
job = execute(qc, backend)
result = job.result()
counts = result.get_counts(qc)
print('counts:',counts)
outputstate = result.get_statevector(qc, decimals=3)
for i,amp in enumerate(outputstate):
    if abs(amp) > 0.000001:
        print('|{}> {}'.format(i, amp))
qc.draw()        # draw the circuit<jupyter_output>|7> (1-0j)
{'fraction_non_alphanumeric': 0.16106442577030813, 'fraction_numerical': 0.025910364145658265, 'mean_word_length': 5.8701923076923075, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '540430', 'license': 'MIT', 'n_tokens_mistral': 626, 'n_tokens_neox': 572, 'n_words': 131, 'path': 'QC Programming/CNOT logic.ipynb', 'repo_name': 'thirasit/Quantum-Computing', 'size': '1428'}