Magician-created Code
Get introduced to the magician-created code, and the heads-and-tails prediction.
We'll cover the following
The magician created a reusable function. It takes as a parameter a callback function—the oracle in line 5. First, we’ll create the QuantumCircuit
with a single qubit in line 8. Tossing the coin sets it into superposition. This is what the first Hadamard gate does in line 11. Then, we apply the oracle in line 14. The magician uses the second Hadamard gate to transform the oracle’s result into the desired state in line 17. Finally, we run the circuit in line 23 and return the results in line 26.
Get hands-on with 1200+ tech skills courses.