Created
March 31, 2020 20:20
-
-
Save tedtanne/6e4bf22d9ee9f06ce918175a225da66c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a Quantum Circuit acting on the q register | |
circuit = QuantumCircuit(2, 2) | |
Add a H gate on qubit 0 | |
circuit.h(0) | |
# Add a CX (CNOT) gate on control qubit 0 and target qubit 1 | |
circuit.cx(0, 1) | |
# Map the quantum measurement to the classical bits | |
circuit.measure([0,1], [0,1]) | |
#Execute Phase: | |
#Use Aer's qasm_simulator | |
simulator = Aer.get_backend('qasm_simulator') | |
Execute the circuit on the qasm simulator | |
job = execute(circuit, simulator, shots=1000) | |
Grab results from the job | |
result = job.result() | |
Return counts | |
counts = result.get_counts(circuit) | |
print("\nTotal count for 00 and 11 are:",counts) | |
#Analyze | |
Draw the circuit | |
circuit.draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is from IBM Quantum Computing.