Tossing two coins simultaneously
So far, we have only played with one coin at a time, but there is nothing stopping us from adding more coins. In this recipe, we will add a coin to the simulation, and toss two coins simultaneously. We will do this by adding a second qubit, expanding the number of qubits – two of everything.
Getting ready
The sample code for this recipe can be found here: https://github.com/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience/blob/master/Chapter04/ch4_r4_two_coin_toss.py.
How to do it...
Set up your code like the previous example, but with a 2-qubit quantum circuit:
- Import the classes and methods that we need:
from qiskit import QuantumCircuit, Aer, execute from qiskit.tools.visualization import plot_histogram from IPython.core.display import display
- Set up our quantum circuit with two qubits and two classical bits:
qc = QuantumCircuit(2, 2)
- Add the Hadamard gates and the measurement gates...