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

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

# Create a Quantum Circuit from the quantum register. Because we're going to use
# the statevector_simulator, we won't measure the circuit or need classical registers.
circ = QuantumCircuit(qr)

# Place an X gate on the 2nd and 3rd wires. The topmost wire is index 0.
circ.x(qr[1])
circ.x(qr[2])

# Draw the 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)

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

# Create the measurement portion of a quantum circuit
meas_circ = QuantumCircuit(qr, cr)

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

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

# Add the measument circuit to the original circuit
complete_circuit = circ + meas_circ

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


# 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(complete_circuit, 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(complete_circuit)
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 3 qubits


# Create a Quantum Circuit from the quantum register. Because we're going to use
# the statevector_simulator, we won't measure the circuit or need classical registers.


# Place Hadamard gate on each of the wires.


# 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


# Create a Classical Register with 3 bits


# Create the measurement portion of a quantum circuit


# Create a barrier that separates the gates from the measurements


# Measure the qubits into the classical registers


# Add the measument circuit to the original circuit


# Draw the new circuit


# 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
