File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ ### Qiskit code to create and measure a Bell state. ####
2+ import numpy as np
3+ from qiskit import QuantumCircuit , execute , Aer
4+ # Create a Quantum Circuit with two qbits and 2 classical bits
5+ circuit = QuantumCircuit (2 ,2 )
6+ # Add a H gate on qubit 0
7+ circuit .h (0 )
8+ # Add a CX (CNOT) gate on control qubit 0 and target qubit 1
9+ circuit .cx (0 ,1 )
10+ # Map the quantum measurement to the classical bits
11+ circuit .measure ([0 ,1 ],[0 ,1 ])
12+ # Use Aer's qasm_simulator
13+ simulator = Aer .get_backend ('qasm_simulator' )
14+ # Execute the circuit on the qasm simulator
15+ job = execute (circuit , simulator , shots = 1000 )
16+ # Grab results from the job
17+ result = job .result ()
18+ # Returns counts
19+ counts = result .get_counts (circuit )
20+ print ("\n Total count for 00 and 11 are:" ,counts )
You can’t perform that action at this time.
0 commit comments