Project 1: The Quantum Coin Flip - Superposition and Measurement

Build a circuit that produces a perfect 50/50 quantum coin flip.


Project Overview

Attribute Value
Difficulty Level 1: Beginner
Time Estimate Weekend
Main Language Python
Alternative Languages Q#, Java
Knowledge Area Superposition
Tools Qiskit or Cirq
Main Book “Quantum Computation and Quantum Information” by Nielsen & Chuang

What you’ll build: A single-qubit circuit that creates a superposition and measures it repeatedly.

Why it teaches quantum: Superposition is the foundational quantum phenomenon.

Core challenges you’ll face:

  • Creating a balanced superposition
  • Running repeated measurements
  • Interpreting randomness statistically

Real World Outcome

You will see near-equal counts for 0 and 1 after many shots.

Example Output:

$ python coin_flip.py --shots 1000
Counts: 0=498, 1=502

Verification steps:

  • Increase shots to see convergence
  • Compare to classical random generator

The Core Question You’re Answering

“How does a single gate create two outcomes at once?”

This is the essence of superposition.


Concepts You Must Understand First

Stop and research these before coding:

  1. Hadamard gate
    • Why does H create equal amplitudes?
    • Book Reference: Nielsen & Chuang, Ch. 2
  2. Measurement
    • Why do we only see classical outcomes?
    • Book Reference: Nielsen & Chuang, Ch. 2
  3. Probability vs amplitude
    • Why do probabilities come from squared magnitudes?
    • Book Reference: Nielsen & Chuang, Ch. 2

Questions to Guide Your Design

  1. Shot count
    • How many shots do you need for stable ratios?
    • How will you display results?
  2. Comparison
    • Will you compare to a classical RNG to show differences?
    • How will you visualize variance?

Thinking Exercise

Hadamard on |0>

Write the state vector after applying H to 0>.

Questions while working:

  • Why do you get 50/50 probabilities?
  • What happens if you apply H again?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “What is superposition?”
  2. “What does the Hadamard gate do?”
  3. “Why are measurement outcomes probabilistic?”
  4. “How does shot count affect results?”
  5. “What is the difference between amplitude and probability?”

Hints in Layers

Hint 1: Starting Point Build a circuit with a single Hadamard gate.

Hint 2: Next Level Run the circuit multiple times and gather counts.

Hint 3: Technical Details Plot the ratio of 0s and 1s as shots increase.

Hint 4: Tools/Debugging Check that counts approach 50/50 with more shots.


Books That Will Help

Topic Book Chapter
Hadamard gate Nielsen & Chuang Ch. 2
Measurement Nielsen & Chuang Ch. 2
Probability Nielsen & Chuang Ch. 2

Implementation Hints

  • Use a simulator backend.
  • Keep circuits minimal for clarity.
  • Repeat runs to show statistical convergence.

Learning Milestones

  1. First milestone: You can create a superposition state.
  2. Second milestone: You can measure and interpret results.
  3. Final milestone: You can explain probabilistic outcomes.