BACK TO HUB

CODING WITH QISKIT

THE DAILY QUBIT | INTERMEDIATE EDITION

Your First Quantum Circuit

Qiskit is IBM's open-source SDK for working with quantum computers. Let's create a simple circuit that puts a qubit into superposition.

from qiskit import QuantumCircuit

# Create a circuit with 1 qubit and 1 classical bit
qc = QuantumCircuit(1, 1)

# Apply a Hadamard gate to put the qubit in superposition
qc.h(0)

# Measure the qubit
qc.measure(0, 0)

# Draw the circuit
print(qc.draw())

Creating a Bell State

A Bell state is the simplest example of quantum entanglement. We use a Hadamard gate followed by a CNOT gate.

qc = QuantumCircuit(2, 2)
qc.h(0)      # Superposition
qc.cx(0, 1)  # Entanglement
qc.measure([0,1], [0,1])
Circuit Diagram

Essential Gates

  • H (Hadamard) Creates superposition. Maps |0⟩ to (|0⟩ + |1⟩)/√2.
  • X (Pauli-X) The quantum NOT gate. Flips |0⟩ to |1⟩ and vice versa.
  • CX (CNOT) Controlled-NOT. Flips the target qubit if the control qubit is |1⟩.

Exclusive Content

Sign in or create an account to unlock full access to our quantum computing content.

FREE ACCESS