microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
source/pip/README.md
55lines · modecode
| 1 | # Q# Language Support for Python |
| 2 | |
| 3 | Q# is an open-source, high-level programming language for developing and running quantum algorithms. |
| 4 | The `qsharp` package for Python provides interoperability with the Q# interpreter, making it easy |
| 5 | to simulate Q# programs within Python. |
| 6 | |
| 7 | ## Installation |
| 8 | |
| 9 | To install the Q# language package, run: |
| 10 | |
| 11 | ```bash |
| 12 | pip install qsharp |
| 13 | ``` |
| 14 | |
| 15 | ## Usage |
| 16 | |
| 17 | First, import the `qsharp` module: |
| 18 | |
| 19 | ```python |
| 20 | import qsharp |
| 21 | ``` |
| 22 | |
| 23 | Then, use the `%%qsharp` cell magic to run Q# directly in Jupyter notebook cells: |
| 24 | |
| 25 | ```qsharp |
| 26 | %%qsharp |
| 27 | |
| 28 | import Std.Diagnostics.*; |
| 29 | |
| 30 | @EntryPoint() |
| 31 | operation BellState() : Unit { |
| 32 | use qs = Qubit[2]; |
| 33 | H(qs[0]); |
| 34 | CNOT(qs[0], qs[1]); |
| 35 | DumpMachine(); |
| 36 | ResetAll(qs); |
| 37 | } |
| 38 | |
| 39 | BellState() |
| 40 | ``` |
| 41 | |
| 42 | ## Telemetry |
| 43 | |
| 44 | This library sends telemetry. Minimal anonymous data is collected to help measure feature usage and performance. |
| 45 | All telemetry events can be seen in the source file [telemetry_events.py](https://github.com/microsoft/qsharp/tree/main/source/pip/qsharp/telemetry_events.py). |
| 46 | |
| 47 | To disable sending telemetry from this package, set the environment variable `QSHARP_PYTHON_TELEMETRY=none` |
| 48 | |
| 49 | ## Support |
| 50 | |
| 51 | For more information about the Azure Quantum Development Kit, visit [https://aka.ms/AQ/Documentation](https://aka.ms/AQ/Documentation). |
| 52 | |
| 53 | ## Contributing |
| 54 | |
| 55 | Q# welcomes your contributions! Visit the Q# GitHub repository at [https://github.com/microsoft/qsharp] to find out more about the project. |
| 56 | |