Try Your Hand
Solutions to these exercises are given in Quantum Logic Gates Solutions.
For any code listing in the exercises, assume the following header lines:
| | OPENQASM 2.0; |
| | include "qelib1.inc"; |
If you want to run any exercise, you must include them in the code you’d like to execute.
-
Write the code for the following circuit:

-
Write the binary states recorded by the Measure gates. Write your answer as a concatenated string of the elements in the classical register.
-
Run your code on a simulator.
-
Run your code on a real quantum computer. Did you get the output you expected?
-
-
Consider the quantum circuit shown here:
- Write a quantum ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access