Tutorials
qcr:2606.29757.1

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 (X**0.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 X**0.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.
Qubit
Circuit-based
Uploaded 4 days ago
11
Views
GitHub4990
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

quantumlib/Cirq
49901228
README.md

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.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

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

v1 Latest
Jun 15, 2026
qcr:2606.29757.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

Cirq

Keywords

getting-started
simulation
superposition
measurement
cirq

You may also like5