# Creating quantum circuits
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister
from qiskit import execute, Aer
from qiskit.tools.visualization import circuit_drawer, plot_histogram


qr =  QuantumRegister(2)
cr = ClassicalRegister(2)
qc = QuantumCircuit(qr, cr)

qc.x(qr[0])
qc.measure(qr, cr)
circuit_drawer(qc)

# Run the circuit
job = execute(qc, backend=Aer.get_backend('qasm_simulator'), shots=1024)
result = job.result()
counts = result.get_counts()
plot_histogram(counts)
print("Counts dictionary:", counts )
print("Probability = ", counts['01']/1024)