Getting Started with Cirq
Overview
Getting Started with Cirq
This is the canonical first program for getting started with Cirq, the quantum-computing equivalent of a "hello world". It constructs a single-qubit circuit, applies a square-root-of-NOT gate (X0.5), measures the qubit, and runs the circuit on Cirq's built-in state-vector simulator for a number of repetitions. The example walks through the core Cirq workflow end to end: allocating a named qubit on a grid, assembling a sequence of operations into a Circuit object, appending a measurement, instantiating a Simulator, and reading back the histogram of measurement outcomes. Because the X0.5 gate places the qubit into an equal superposition before measurement, repeated runs return a roughly balanced mix of 0 and 1 results, illustrating quantum randomness in the simplest possible setting. It is intentionally minimal, so newcomers can see how qubits, gates, circuits, simulation, and measurement fit together without the distraction of a full algorithm, making it an ideal starting point before moving on to teleportation, the quantum Fourier transform, or any of the named algorithms in this collection.
Run it
pip install -r requirements.txt
python hello_qubit.py
Source and license
Imported from examples/hello_qubit.py in quantumlib/Cirq at v1.6.1, under the Apache License 2.0. Original authors: The Cirq Developers. The upstream LICENSE is included alongside this example.
This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.
Versions
Cite all versions? Use the base QCR ID to always reference the latest version of this entry.
Join the Discussion
Comments (0)
No comments yet. Be the first to share your thoughts!