Running your first program

To execute your first program, we will run a simple quantum coin-toss program using the QVM simulator. This program prepares a quantum state which is in an equal superposition of the 0>|0> (heads) and 1>|1> (tails) states on three separate qubits (coins). It uses quantum mechanics to randomly select between heads and tails, similar to flipping a coin. This program, with the filename hello_world.py, is already included in the home directory of your IDE in the getting-started folder.

  1. Launch your JupyterLab IDE

  2. Open a terminal and simply run :

    python hello_world.py
  3. you should see an output similar to the following:

You can see that 3 qubits (each column) gave random results for this experiment over 10 coin flips (each row). If you run this program many times, you will see different random results each time, but the percentage of results which are 0 or 1 will each approach 50%, like a fair coin. We invite you to look inside hello_world.py to see how the program was built and executed using pyQuil. We've included verbose comments to explain each step. You can quickly do this with the following command:

cat hello_world.py

Great! Your IDE is now set up and you've used it to successfully simulate a quantum program. Check out the Forest™ SDK documentation to develop your own program, and then after testing it on the QVM simulator, learn how to use the command-line interface to execute your program on the real quantum hardware.