You should include shots value. Shots is nothing but how many times the circuit going to run. Because Quantum computing is all about being probabilistic (i.e.) you can't be certain about the results till you measure and once measured qubits collapses to a particular state according to the gates you have used. So, what you are doing here is, you are measuring the circuit using qasm_simulator
. so, you should definitely give shots. Shots can be any number. It can be 1000, 1024 and so on.
qc = QuantumCircuit(2)
qc.h([0])
qc.cx(0, 1)
qc.measure_all()
qc.draw('mpl')
Execute the above code in a separate cell for better results.
simulator = Aer.get_backend('qasm_simulator')
job = execute(qc, simulator , shots = 1000)
result = job.result()
counts=result.get_counts(qc)
plot_histogram(counts)
This is my version of the code and its working fine for me.
You should get output like this:
00
and 11
with graph.