import qiskit
qiskit.__version__

qiskit.__qiskit_version__

#Import the required packages
from qiskit import QuantumCircuit, QuantumRegister,ClassicalRegister,Aer,execute
from qiskit.visualization import *


qc1=QuantumCircuit(2)
qc1.x(0)
qc1.cx(0,1)
qc1.draw('mpl')

backend=Aer.get_backend('statevector_simulator')
job=execute(qc1,backend)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

qc2=QuantumCircuit(2)
qc2.x(0)
qc2.cnot(0,1)
qc2.draw('mpl')

backend=Aer.get_backend('statevector_simulator')
job=execute(qc2,backend)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

# We create 5-qubit mct gate
# We have a list of control qubits :0,1,2,3 and a target qubit 4.
qc3=QuantumCircuit(5)
qc3.x(range(4))
qc3.mct([0,1,2,3],4)
qc3.draw('mpl')

backend=Aer.get_backend('statevector_simulator')
job=execute(qc3,backend)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

qc4=QuantumCircuit(2)
qc4.cz(0,1)
qc4.draw('mpl')

backend=Aer.get_backend('statevector_simulator')
job=execute(qc4,backend)
result=job.result()
sv=result.get_statevector()
print("statevector:", sv)
sv.draw(output="latex")

backend=Aer.get_backend('unitary_simulator')
job=execute(qc4,backend)
result=job.result()
sv=result.get_unitary()
print(sv)


#Let's apply a X on the control qubit
qc4=QuantumCircuit(2)
qc4.x(0)
qc4.cz(0,1)
qc4.draw('mpl')

backend=Aer.get_backend('statevector_simulator')
job=execute(qc4,backend)
result=job.result()
sv=result.get_statevector()
print("statevector:", sv)
sv.draw(output="latex")

backend=Aer.get_backend('unitary_simulator')
job=execute(qc4,backend)
result=job.result()
sv=result.get_unitary()
print(sv)

plot_state_qsphere(sv,show_state_phases=True)

