Getting Started

Welcome to Quantum Katas

kaˑ ta | kah-tuh The Japanese word for "form", a pattern of learning and practicing new skills.

Self-paced AI-assisted learning
Quantum katas are self-paced learning tutorials assisted by Copilot in Microsoft Quantum.
Focused on quantum computing and programming
The Quantum katas focus on teaching quantum computing concepts and quantum programming using the Q# language.
Tutorials with theory and interactive hands-on exercises
Each tutorial includes relevant theory and supporting interactive exercises designed to test knowledge.

Exercise: Flip a Qubit

Exercises are problems that you have to solve by writing Q# code. In each exercise, you'll be presented with placeholder code that you'll have to fill in with the correct solution.

Input: A qubit in the |0 state.

Goal: Apply the X gate to the qubit, that is, perform a "bit flip" to set the qubit into the |1 state.

Need a hint? For some problems a hint will be provided to help you if you are stuck. For this exercise, read line number 3 in the code below.
namespace Kata {
    operation FlipQubit(q : Qubit) : Unit is Adj + Ctl {
        // Uncomment the following line to solve this exercise.
        //X(q);
    }
}

Solution

Once you've successfully implemented a solution or if you're stuck on a problem, you can consult the reference solution, which contains additional details on how to solve the exercise.

For this exercise, you can solve the problem by simply using Q#'s X operation on the input qubit, which will perform a "bit flip" and set the qubit into the |1 state.

namespace Kata {
    operation FlipQubit(q : Qubit) : Unit is Adj + Ctl {
        // Perform a "bit flip" on the qubit by applying the X gate.
        X(q);
    }
}