from qiskit import *

from qiskit.tools.visualization import plot_bloch_multivector

circuit = QuantumCircuit(1,1) #init ckt
circuit.x(0)

#Simulate it
simulator = Aer.get_backend('statevector_simulator') #statevector describes the quantum gate state
result = execute(circuit, backend=simulator).result()
statevector = execute(circuit, backend=simulator).result().get_statevector()
print(statevector)

#draw ckt
%matplotlib inline
circuit.draw()

#block sphere
plot_bloch_multivector(statevector)

circuit.measure([0], [0])
backend = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=backend, shots = 1024).result()
counts = result.get_counts()
from qiskit.tools.visualization import plot_histogram
plot_histogram(counts)

circuit = QuantumCircuit(1,1) #init ckt
circuit.x(0)
#Simulate it
simulator = Aer.get_backend('unitary_simulator') #notice unitary over statevector
result = execute(circuit, backend=simulator).result()
unitary = result.get_unitary()
print(unitary)
%matplotlib inline
circuit.draw()