Using the Grover circuit in your own code
There's quite a bit of code going into the combined ch9_r3_grover_main.py
and ch9_grover_functions.py
scripts. The interactive main program is not needed to just run Grover if, for example, you want to utilize it in another Python program.
Getting ready
The sample Grover functions code that you need is included here: https://github.com/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience/blob/master/Chapter09/ch9_grover_functions.py.
How to do it…
- Technically, all you need to do is to include the following short code snippet in your own code:
from ch9_grover_functions import * oracle=create_oracle("01",2) amplifier=create_amplifier(2) grover=create_grover(oracle,amplifier,False) print(grover)
- The preceding code should give the following result: