Created
March 22, 2021 05:38
-
-
Save victor-iyi/c22766fab6f219d16537a04c3b5d2671 to your computer and use it in GitHub Desktop.
Hello World Quantum computing using Google's cirq library
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
import cirq | |
# print(cirq.google.Sycamore) | |
a = cirq.NamedQubit('a') | |
b = cirq.NamedQubit('b') | |
# Create Circuit (logic-gate like) | |
circuit = cirq.Circuit( | |
cirq.H(a), | |
cirq.CNOT(a, b), | |
cirq.measure(a, b) | |
) | |
print(circuit) | |
# print(repr(circuit)) | |
for i, moment in enumerate(circuit): | |
print(f'Moment - {i}: {moment}') | |
# Run on a simulator | |
simulator = cirq.Simulator() | |
# Run circuit on simulator with 20 repetitions. | |
simulator.run(circuit, repetitions=20) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment