# !pip install qiskit==0.7.1
# Include the necessary imports for this program
import numpy as np
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute

# Create a Quantum Register with 2 qubits
qr = QuantumRegister(2)

# Create a Classical Register with 2 bits
cr = ClassicalRegister(2)

# Create a Quantum Circuit from the quantum and classical registers
circ = QuantumCircuit(qr, cr)

# Place Hadamard gate on the top wire, putting this qubit in a superposition.
circ.h(qr[0])

# Add a CX (CNOT) gate across the top two wires, entangling the qubits.
circ.cx(qr[0], qr[1])

# Create a barrier that separates the gates from the measurements
circ.barrier(qr)

# Measure the qubits into the classical registers
circ.measure(qr, cr)

# Draw the new circuit
circ.draw(output='mpl')


# Use the BasicAer statevector_simulator backend
from qiskit import BasicAer
backend_sv_sim = BasicAer.get_backend('statevector_simulator')

# Execute the circuit on the state vector simulator
job_sim = execute(circ, backend_sv_sim)

# Grab the results from the job.
result_sim = job_sim.result()

# Obtain the state vector for the quantum circuit
quantum_state = result_sim.get_statevector(circ, decimals=3)

# Output the quantum state vector in a manner that contains a comma-delimited string.
quantum_state

# Plot the state vector on a Q-sphere
from qiskit.tools.visualization import plot_state_qsphere
plot_state_qsphere(quantum_state)

# Use the BasicAer qasm_simulator backend
from qiskit import BasicAer
backend_sim = BasicAer.get_backend('qasm_simulator')

# Execute the circuit on the qasm simulator, running it 1000 times.
job_sim = execute(circ, backend_sim, shots=1000)

# Grab the results from the job.
result_sim = job_sim.result()

# Print the counts, which are contained in a Python dictionary
counts = result_sim.get_counts(circ)
print(counts)

# Plot the results on a histogram
from qiskit.tools.visualization import plot_histogram
plot_histogram(counts)

# Include the necessary imports for this program


# Create a Quantum Register with 2 qubits


# Create a Classical Register with 2 bits


# Create a Quantum Circuit from the quantum and classical registers


# Place appropriate gates on the wires to achieve the desired Bell state


# Create a barrier that separates the gates from the measurements


# Measure the qubits into the classical registers


# Draw the circuit


# Use the BasicAer statevector_simulator backend


# Execute the circuit on the state vector simulator


# Grab the results from the job.


# Obtain the state vector for the quantum circuit


# Output the quantum state vector in a manner that contains a comma-delimited string.


# Plot the state vector on a Q-sphere


# Use the BasicAer qasm_simulator backend


# Execute the circuit on the qasm simulator, running it 1000 times.


# Grab the results from the job.


# Print the counts, which are contained in a Python dictionary


# Plot the results on a histogram
