Return outputs with zero counts

Quantum Computing Asked by LOC on December 2, 2020

I am running a simple 3 qubit circuit which produces the following results:

{'000': 5, '001': 3, '010': 10, '100': 5, '101': 7, '110': 7, '111': 4}


There are no counts of 011. Is there a simple way within qiskit to also return the result ‘011’: 0? So the final results would be

{'000': 5, '001': 3, '010': 10,'011': 0, '100': 5, '101': 7, '110': 7, '111': 4}


Currently when I run this circuit I get an error as I am trying to call res[‘011’], where res is the list of results. I cannot just increase the number of shots unfortunately I am constrained to this number of qubits.

You can use .get() and return zero as the default value.

res.get('011', 0)

Correct answer by tsgeorgios on December 2, 2020

Related Questions

Cirq: Result of rotating qubit measurements never come [0 1] or [1 0 ], always come as [0,0] or [1,1]

1  Asked on May 18, 2021

What role do Hecke operators and ideal classes perform in “Quantum Money from Modular Forms?”

1  Asked on May 17, 2021

The Methodology of Quantum Key Distributions Systems

1  Asked on May 16, 2021

Writing the Jaynes-Cumming model in QuTip

1  Asked on May 16, 2021

QUBO, Ising Hamiltonians and VQA

1  Asked on May 16, 2021 by karolyzz

Are all pure entangled states `robust’?

2  Asked on May 15, 2021 by rammus

Unitary Operator impact on both – the Control Qubit and the Target Register in Shor’s Algorithm

1  Asked on May 15, 2021 by dhiraj-gupta

Quantum algorithms for Prolog or automated theorem proving?

0  Asked on May 15, 2021

Is HHL still BQP-complete when the matrix entries are only in {0,1}?

0  Asked on May 15, 2021

Why does $sum_n langle n|M_mrho M_m^dagger|nrangle$ simplify to $langle psi|M_m^dagger M_m|psirangle$?

1  Asked on May 14, 2021

Gate SWAP vs Physical SWAP in Trapped Ions for chain reordering

1  Asked on May 13, 2021 by alexvilloria26

How to prove that EPR outcomes have equal probability no matter the basis?

2  Asked on May 13, 2021

Why do the constant operations in a quantum computer need second qubits?

1  Asked on May 13, 2021 by mysteriouswaffle

qiskit: IQFT acting on subsystem of reversed-ordered qubits state

2  Asked on May 13, 2021

How to apply a operator to qubit system on the basis of current state of system?

1  Asked on May 12, 2021

What is the motivation for Weyl matrices in quantum information theory?

0  Asked on May 12, 2021

quantum circuit with feasible gates for state preparation

1  Asked on May 12, 2021 by bmp

How to measure a general two-qubits gate? Does it help to Bob and Alice?

1  Asked on May 11, 2021

Easiest hash function to implement on Qiskit

1  Asked on May 11, 2021 by corbs

How to transpile a circuit using Qiskit as done in IBMQ experience

4  Asked on May 10, 2021