## Doing nothing with Qiskit Terra¶

We are going to use Qiskit to do nothing.

In [1]:
import qiskit


First we set up an empty program for one qubit.

In [2]:
qr = qiskit.QuantumRegister(1)
cr = qiskit.ClassicalRegister(1)
program = qiskit.QuantumCircuit(qr, cr)


We don't want to do anything to the qubit, so we'll skip straight to reading it out.

In [3]:
program.measure(qr,cr)

Out[3]:
<qiskit.circuit.instructionset.InstructionSet at 0x10cda4e80>

Now we'll tell the local simulator to execute this entirely trivial program.

In [4]:
job = qiskit.execute( program, qiskit.BasicAer.get_backend('qasm_simulator') )


And then print out the result. Since qubits are initialized as 0, and we did nothing to our qubit before readout, we'll just get the result 0 many times.

In [5]:
print( job.result().get_counts() )

{'0': 1024}


Now let's try it on the least busy real device. This will have a few samples which output 1 due to noise, but most of the samples should be for an output of 0.

In [6]:
qiskit.IBMQ.load_accounts()
backend = qiskit.providers.ibmq.least_busy(qiskit.IBMQ.backends(simulator=False))
print("We'll use the least busy device:",backend.name())
job = qiskit.execute( program, backend )
print( job.result().get_counts() )

We'll use the least busy device: ibmqx4
{'0': 1004, '1': 20}


If this all ran successfully, you are now ready to create and execute programs that actually do something!