Hello Qubit

View on QuantumAI Run in Google Colab View source on GitHub Download notebook
try:
    import cirq
except ImportError:
    print("installing cirq...")
    !pip install --quiet cirq
    import cirq
    print("installed cirq.")
# Pick a qubit.
qubit = cirq.GridQubit(0, 0)

# Create a circuit
circuit = cirq.Circuit(
    cirq.X(qubit)**0.5,  # Square root of NOT.
    cirq.measure(qubit, key='m')  # Measurement.
)
print("Circuit:")
print(circuit)

# Simulate the circuit several times.
simulator = cirq.Simulator()
result = simulator.run(circuit, repetitions=20)
print("Results:")
print(result)
Circuit:
(0, 0): ───X^0.5───M('m')───
Results:
m=01110011010101001001

Congratulations

You've just run your first Cirq program. If you would like to learn more about quantum computing, check out our education page. The Full API reference for Cirq can be found here. If you are looking for vendor specific information that can be found on our vendor sub-pages:

Alpine Quantum Technologies

Pasqal

IonQ

Azure

Rigetti