<jupyter_start><jupyter_text>Two qubits<jupyter_code>import numpy as np
import pandas as pd

from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute
from qiskit.tools import visualization
from qiskit import BasicAer as Aer

import matplotlib.pyplot as plt
%matplotlib auto

from IPython.display import Latex
from IPython.display import Math

import ancillary_functions as anf<jupyter_output>Using matplotlib backend: Qt5Agg<jupyter_text>Preliminary task  Create two-qubit circuit and perform X gate on one of them. * Try to use it only on first qubit, later only on second qubit. * Test how results are numbered. You may change mapping to classical register when you measure.* Check what is the convention for numbering qubits in state vector.* This may seem a little silly, but it's actually quite easy to get lost in naming conventions if you won't try it yourself.<jupyter_code># specify variables
qrs =
crs =
circuit_name =
nos =
backend_name =
backend = Aer.get_backend(backend_name)

circuit, qreg, creg = anf.create_circuit_draft(qrs=qrs, crs=crs, circuit_name=circuit_name)

# add things to circuit

# ....


# perform experiments
job = execute(circuit, backend=backend, shots=nos)
results = job.result();

counts = results.get_counts()
print(counts)<jupyter_output><empty_output><jupyter_text>Two-qubit gates  CNOT* The most important two-qubit gate is controlled-NOT (CNOT) gate.* One qubit is called CONTROL, the other one is called TARGET.* The gate simply applies NOT gate to the TARGET, if CONTROL is in |1> state. * If CONTROL is in |0> state, it does nothing.<jupyter_code>qrs = 2
crs = 2
circuit_name = 'cnot'
nos = 8192
backend_name = 'qasm_simulator'
backend = Aer.get_backend(backend_name)

circuit, qreg, creg = anf.create_circuit_draft(qrs=qrs, crs=crs, circuit_name=circuit_name)

# CONTROL QUBIT, TARGET QUBIT
circuit.cx(qreg[0], qreg[1])

# Measure 
circuit.measure(qreg[0], creg[0])
circuit.measure(qreg[1], creg[1])

# perform experiments
job = execute(circuit, backend=backend, shots=nos)
results = job.result();

counts = results.get_counts()
print(counts)<jupyter_output>{'00': 8192}<jupyter_text>* Since our control qubit is in |0> state, our gate does nothing.<jupyter_code>print(circuit)<jupyter_output>┌─┐   
qreg_cnot_0: |0>──■──┤M├───
                ┌─┴─┐└╥┘┌─┐
qreg_cnot_1: |0>┤ X ├─╫─┤M├
                └───┘ ║ └╥┘
 creg_cnot_0: 0 ══════╩══╬═
                         ║ 
 creg_cnot_1: 0 ═════════╩═
{'fraction_non_alphanumeric': 0.11011783827712313, 'fraction_numerical': 0.012190166598943519, 'mean_word_length': 4.990267639902676, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 19, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '494057', 'license': 'MIT', 'n_tokens_mistral': 919, 'n_tokens_neox': 865, 'n_words': 266, 'path': 'exercises/CW_0_1.ipynb', 'repo_name': 'fbm2718/qiskit_classes_PW2020', 'size': '2461'}