Single-Qubit Gates and Circuit Composition

Beginner Quantum Gates
Created by Pavel · 11.03.2026 at 14:32 UTC

Single-qubit gates are $2\times 2$ unitaries composed in time order. $X$ swaps populations, $Z$ adds phase to the $|1\rangle$ component, $H$ bridges computational and Hadamard bases; identities such as $HZH=X$ show how basis changes move effects between “phase” and “bit-flip” stories.

Order matters because matrices rarely commute—swap two gates and you may change the entire measurement distribution. [1].


Sources

University approvals: 0
Tasks
Question 1

Applying $X$ to $|0\rangle$ gives:

Hint

X is a bit flip.

Question 2

Applying $H$ to $|0\rangle$ gives:

Hint

The equal positive superposition.

Question 3

What does Z primarily change on a qubit state?

Hint

Not population swap.

Question 4

A short circuit with H then Z differs from H then X mainly because:

Hint

Compare action type.

Question 5

In one sentence, why do we call these operations unitary?

Hint

Norm preservation.

Question 6

Starting from $|0\rangle$, what is $P(\text{measure }1)$ after the sequence $H \to Z \to H$?

Hint

H Z H equals X.

Question 7

What does the identity H Z H = X most clearly illustrate?

Hint

Think basis transformation.

Question 8

Why is non-commutativity important when designing circuits?

Hint

Matrix multiplication order matters in general.

Question 9

Implement hadamard_plus_amplitudes() -> tuple[complex, complex] returning complex amplitudes $(a_0, a_1)$ of $H|0\rangle$ in the computational basis, i.e. $(1/\sqrt2, 1/\sqrt2)$.

Hint

Use math.sqrt for denominators; return two complex numbers.

Starter code is prefilled; replace TODO blocks with your solution.
2 test cases will be used for grading
Run checks runtime behavior only. Final correctness is evaluated when you submit.
Card Info
  • Topic: Quantum Gates
  • Difficulty: Beginner
  • Completed: 0 users
Creator
Pavel
Pavel