Answer
- Start an Anaconda prompt console. Type
anaconda
in the Windows search box and click on Anaconda prompt when it appears in the search list. A console window will appear. - Enter the
qiskitenv
environment with this command:conda activate qiskitenv
- Enter the following commands at the Anaconda prompt:
python import numpy as np from qiskit import *
- Create a quantum circuit containing a three-qubit GHZ state and add measurements for each qubit:
circ = QuantumCircuit(3) # Add an H gate to qubit 0, creating superposition circ.h(0) # Add a CX (CNOT) gate. Qubit 0 is control and qubit 1 is target circ.cx(0,1) # Add a CX (CNOT) gate. Qubit 0 is control and qubit 2 is target circ.cx(0,2) # Add a measurement to each of the qubits meas = QuantumCircuit(3, 3) meas.barrier(range(3)) meas.measure(range(3),range(3)) # Combine the two circuits qc = circ + meas
- Display the circuit onscreen:
qc.draw()
The output of this command should appear as follows:
>>> qc.draw() ...