Welcome

This is a Binder repository containing tutorial notebooks for learning about pyQuil and the Forest SDK (quilc and the QVM). The table of contents for the repository can be found at the bottom of this notebook. If you'd like to add a notebook, or change an existing one, make a pull request to the rigetti/forest-tutorials repository!

The Basics

In [1]:
from pyquil import get_qc, Program
from pyquil.gates import H, CNOT, MEASURE
In [2]:
qvm = get_qc("2q-qvm")
In [3]:
p = Program()
p += H(0)
p += CNOT(0, 1)
ro = p.declare('ro', 'BIT', 2)
p += MEASURE(0, ro[0])
p += MEASURE(1, ro[1])
p.wrap_in_numshots_loop(10)
print(p)
H 0
CNOT 0 1
DECLARE ro BIT[2]
MEASURE 0 ro[0]
MEASURE 1 ro[1]

In [4]:
qvm.run(p)
Out[4]:
array([[1, 1],
       [0, 0],
       [1, 1],
       [0, 0],
       [0, 0],
       [0, 0],
       [0, 0],
       [0, 0],
       [1, 1],
       [1, 1]])