from qiskit import *
from qiskit.quantum_info import Statevector
from math import pi

# No barrier gate present
qc=QuantumCircuit(3)
qc.h(range(2))
qc.x(2)
qc.draw(output="mpl")

#Let's apply a barrier gate with no arguments
qc=QuantumCircuit(1)
qc.h(0)
qc.h(0)
qc.barrier()  
qc.y(0)
qc.draw(output="mpl")

#Let's apply a barrier gate with no arguments for a 3-qubit Quantum Circuit
# If we don't specify any arguments, then the barrier is applied across all the qubits
qc=QuantumCircuit(3)
qc.h(range(2))
qc.barrier()
qc.x(2)
qc.draw(output="mpl")

#Let's apply a barrier gate with 1 arguments for a 3-qubit Quantum Circuit
# We want to apply a barrier only to the q0
qc=QuantumCircuit(3)
qc.h(range(2))
qc.barrier(0)
qc.x(2)
qc.draw(output="mpl")

qc=QuantumCircuit(3)
qc.h(range(2))
qc.barrier(0,1)
qc.x(2)
qc.draw(output="mpl")

# barrier is applied to q0 and q1

qc=QuantumCircuit(3)
qc.h(range(2))
qc.barrier(0,1,2)
qc.x(2)
qc.draw(output="mpl")

qc=QuantumCircuit(3)
qc.h(range(2))
qc.x(2)
qc.ccx(0,1,2)
qc.ry(pi,0)
qc.ch(1,2)
qc.tdg(2)
qc.cx(1,0)
qc.draw(output="mpl")

qc=QuantumCircuit(3)
qc.h(range(2))
qc.barrier()
qc.x(2)
qc.barrier()
qc.ccx(0,1,2)
qc.barrier()
qc.ry(pi,0)
qc.ch(1,2)
qc.barrier()
qc.tdg(2)
qc.barrier()
qc.cx(1,0)
qc.draw(output="mpl")

qr=QuantumRegister(3)
qc=QuantumCircuit(qr)
qc.x(0)
qc.barrier(qr)
qc.h(1)
qc.barrier(qr)
qc.s(1)
qc.barrier(qr)
qc.h(2)
qc.draw(output="mpl")