from qiskit import *
from math import pi
import numpy as np
from qiskit.visualization import plot_bloch_multivector, plot_histogram

qc = QuantumCircuit(3)
for qubit in range(3):
    qc.h(qubit)
qc.draw()

backend = Aer.get_backend('statevector_simulator')
final_state = execute(qc, backend).result().get_statevector()
print(final_state)

qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
qc.draw()

backend = Aer.get_backend('unitary_simulator')
unitary = execute(qc, backend).result().get_unitary()

print(unitary)

qiskit.__qiskit_version__


qc = QuantumCircuit(3)
qc.x(0)
qc.z(1)
qc.h(2)
qc.draw()

unitary = execute(qc, backend).result().get_unitary()
print(unitary)

qc = QuantumCircuit(2)
# Apply H-gate to the first:
qc.h(0)
qc.draw()

backend = Aer.get_backend('statevector_simulator')
final_state = execute(qc,backend).result().get_statevector()
print(final_state)

qc = QuantumCircuit(2)
# Apply H-gate to the first:
qc.h(0)
# Apply a CNOT:
qc.cx(0,1)
qc.draw()

final_state = Aer.get_backend('statevector_simulator')
final_state = execute(qc, backend).result().get_statevector()
print(final_state)

results = execute(qc,backend).result().get_counts()
plot_histogram(results)


qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
qc.cx(0,1)
qc.draw()

backend  =  Aer.get_backend('statevector_simulator')
result  = execute(qc, backend).result().get_statevector()
print(result)

result = execute(qc, backend).result().get_counts()
plot_histogram(result)

backend  =  Aer.get_backend('unitary_simulator')
unitary = execute(qc, backend).result().get_unitary()
print(unitary)

