#Quantum gates basics 
from qiskit import *
from qiskit.tools.visualization import plot_bloch_multivector
from qiskit.tools.visualization import plot_histogram
import matplotlib

circuit = QuantumCircuit(1,1) #one qubit one classical bit (one operation )
circuit.x(0) 
simulator = Aer.get_backend('statevector_simulator') #describes the quantum state of the qbit
result = execute(circuit, backend= simulator).result()
statevector= result.get_statevector()
print(statevector)
circuit.draw(output='mpl')

#plotting bloch vector
plot_bloch_multivector(statevector)

circuit.measure([0],[0])
simulator= Aer.get_backend('qasm_simulator')
result = execute(circuit, backend= simulator, shots=1023).result()
plot_histogram(result.get_counts(circuit))


#displaying results in matrices 
circuit = QuantumCircuit(1,1)
circuit.x(0)
simulator = Aer.get_backend('unitary_simulator') #unitary simulator for matrix representation
result = execute(circuit,backend=simulator).result()
unitary= result.get_unitary()
print(unitary)

