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 that applies a square root of NOT gate, then measures the qubit.
circuit = cirq.Circuit(cirq.X(qubit) ** 0.5, cirq.measure(qubit, key='m'))
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=00110001111101100001

Congratulations

You've just run your first Cirq program.

To learn about running a circuit on a virtual machine that mimics existing quantum hardware, see Quantum Virtual Machine.

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