← Quantum Store · Guides · Lessons · Glossary · Packages · About · Türkçe

Microsoft Quantum

Microsoft QDK and Q# starter package

SoftwareQuantum SDKLicence: MITVersion: 1.33.05.3 KB

Official source: microsoft/qdk

Download ZIP (free)

Microsoft Quantum Development Kit: a tested Bell state example written in Q# and run from Python, plus a guide to resource estimation.

What is the Microsoft QDK?

The Quantum Development Kit (QDK) is an open-source package containing Microsoft's quantum programming language Q#, its compiler, simulator and resource estimation tool. Q# is designed for writing quantum algorithms in a hardware-independent, type-safe language.

When to use it

The example in this package

bell_qsharp.py compiles Q# code from within Python and runs it 200 times. In every run the two qubits give the same result.

Note

The old qsharp Python package is being deprecated; install the qdk package instead and import it with from qdk import qsharp.

Next steps

  1. Install the "Azure Quantum Development Kit" extension for VS Code.
  2. Use qsharp.estimate(...) to compute the physical resources your own algorithm needs.

Installation and running

pip install qdk
python bell_qsharp.py

Tested with: qdk 1.33.1, Python 3.12.

Official source

Links

Package contents

Licence

The example code and the guide in this package were written by the Quantum Store editors and are MIT licensed. The project it uses is subject to its own licence (MIT).


Quantum Store — https://hakanerdogan.com/en

Example code

The example shipped in the package, run and checked. Comments and printed messages are in Turkish; the code is the same in any language. Everything is in the ZIP.

bell_qsharp.py

"""Microsoft Quantum Development Kit: Python içinden Q# çalıştır.

Çalıştırma:
    pip install qdk
    python bell_qsharp.py
"""

from qdk import qsharp

qsharp.eval(
    """
    operation Bell() : (Result, Result) {
        use (a, b) = (Qubit(), Qubit());
        H(a);
        CNOT(a, b);
        let results = (M(a), M(b));
        ResetAll([a, b]);
        return results;
    }
    """
)

shots = qsharp.run("Bell()", shots=200)
same = sum(1 for a, b in shots if a == b)
print(f"200 çalıştırmadan {same} tanesinde iki kübit aynı sonucu verdi.")
print("İlk 5 sonuç:", shots[:5])

assert same == len(shots)
print("Tamam: Q# Bell durumu doğrulandı.")

← All packages

Share: X · LinkedIn