Skip to content

Commit 00f9d12

Browse files
authored
Merge pull request #50823 from v-thpra/azure-triage-fix-1055091
Technical Review 1055091: Create your first Q# program by using the Quantum Development Kit
2 parents def6254 + d9f658d commit 00f9d12

File tree

12 files changed

+271
-276
lines changed

12 files changed

+271
-276
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.quantum.qsharp-create-first-quantum-development-kit.1-introduction
3-
title: Introduction
4-
metadata:
5-
title: Introduction
6-
description: Introduction
7-
ms.date: 10/30/2024
8-
author: azure-quantum-content
9-
ms.author: quantumdocwriters
10-
11-
ms.topic: unit
12-
durationInMinutes: 1
13-
content: |
14-
[!include[](includes/1-introduction.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.quantum.qsharp-create-first-quantum-development-kit.1-introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: Introduction
7+
ms.date: 06/09/2025
8+
author: azure-quantum-content
9+
ms.author: quantumdocwriters
10+
11+
ms.topic: unit
12+
durationInMinutes: 1
13+
content: |
14+
[!include[](includes/1-introduction.md)]
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.quantum.qsharp-create-first-quantum-development-kit.qsharp-structure
3-
title: What are the main components of a Q# program?
4-
metadata:
5-
title: How are Q# programs structured?
6-
description: Learn the structure of a basic Q# program.
7-
ms.date: 10/30/2024
8-
author: azure-quantum-content
9-
ms.author: quantumdocwriters
10-
11-
ms.topic: unit
12-
durationInMinutes: 6
13-
content: |
14-
[!include[](includes/2-qsharp-structure.md)]
15-
1+
### YamlMime:ModuleUnit
2+
uid: learn.quantum.qsharp-create-first-quantum-development-kit.qsharp-structure
3+
title: What are the main components of a Q# program?
4+
metadata:
5+
title: How are Q# programs structured?
6+
description: Learn the structure of a basic Q# program.
7+
ms.date: 06/09/2025
8+
author: azure-quantum-content
9+
ms.author: quantumdocwriters
10+
11+
ms.topic: unit
12+
durationInMinutes: 6
13+
content: |
14+
[!include[](includes/2-qsharp-structure.md)]
15+
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.quantum.qsharp-create-first-quantum-development-kit.4-random-bit-generator
3-
title: Exercise Part 1 - Create a quantum random bit generator
4-
metadata:
5-
title: Exercise - Create a quantum random bit generator
6-
description: Write Q# code that generates a single random bit.
7-
ms.date: 10/30/2024
8-
author: azure-quantum-content
9-
ms.author: quantumdocwriters
10-
11-
ms.topic: unit
12-
show_latex: true
13-
durationInMinutes: 8
14-
content: |
15-
[!include[](includes/3-random-bit-generator.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.quantum.qsharp-create-first-quantum-development-kit.4-random-bit-generator
3+
title: Exercise Part 1 - Create a quantum random bit generator
4+
metadata:
5+
title: Exercise - Create a quantum random bit generator
6+
description: Write Q# code that generates a single random bit.
7+
ms.date: 06/09/2025
8+
author: azure-quantum-content
9+
ms.author: quantumdocwriters
10+
11+
ms.topic: unit
12+
show_latex: true
13+
durationInMinutes: 8
14+
content: |
15+
[!include[](includes/3-random-bit-generator.md)]
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.quantum.qsharp-create-first-quantum-development-kit.5-random-number-generator
3-
title: Exercise Part 2 - Create a quantum random number generator
4-
metadata:
5-
title: Exercise - Create a quantum random number generator
6-
description: Write classical code to extend your random bit program to generate larger numbers.
7-
ms.date: 10/30/2024
8-
author: azure-quantum-content
9-
ms.author: quantumdocwriters
10-
11-
ms.topic: unit
12-
show_latex: true
13-
durationInMinutes: 10
14-
content: |
15-
[!include[](includes/4-random-number-generator.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.quantum.qsharp-create-first-quantum-development-kit.5-random-number-generator
3+
title: Exercise Part 2 - Create a quantum random number generator
4+
metadata:
5+
title: Exercise - Create a quantum random number generator
6+
description: Write classical code to extend your random bit program to generate larger numbers.
7+
ms.date: 06/09/2025
8+
author: azure-quantum-content
9+
ms.author: quantumdocwriters
10+
11+
ms.topic: unit
12+
show_latex: true
13+
durationInMinutes: 10
14+
content: |
15+
[!include[](includes/4-random-number-generator.md)]
Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.quantum.qsharp-create-first-quantum-development-kit.knowledge-check
3-
title: Module assessment
4-
metadata:
5-
title: Module assessment
6-
description: Check your understanding so far.
7-
author: azure-quantum-content
8-
ms.author: quantumdocwriters
9-
10-
ms.date: 10/30/2024
11-
ms.topic: unit
12-
ai-usage: ai-assisted
13-
durationInMinutes: 7
14-
content: |
15-
[!include[](includes/5-knowledge-check.md)]
16-
17-
quiz:
18-
title: Check your knowledge
19-
questions:
20-
21-
- content: 'Which of these statements is true about the random number generator that you built in this module?'
22-
choices:
23-
- content: "The quantum random number generator takes the current time from the CPU's clock as a seed to generate random numbers."
24-
isCorrect: false
25-
explanation: "The quantum random number generator doesn't use the CPU's clock to generate random numbers. A classical pseudo-random number generator would do that."
26-
- content: "The quantum random number generator creates one qubit, measures it, and the result of the measurement is a random decimal number."
27-
isCorrect: false
28-
explanation: "The result of the measurement of a qubit is a random bit, not a random decimal number. This isn't the logic behind the random number generator that you built in this module."
29-
- content: "The quantum random number generator creates a bit string from the repetition of measurements of a qubit in superposition. Then, it takes the bit string and converts it to a decimal number."
30-
isCorrect: true
31-
explanation: "This is the logic behind the random number generator that you built in this module."
32-
33-
- content: 'Which of the following structures are required for a Q# program to run successfully?'
34-
choices:
35-
- content: 'To run successfully, a Q# program must have a function.'
36-
isCorrect: false
37-
explanation: "A function is not required in a Q# program."
38-
- content: "To run successfully, a Q# program must have an entry point, which is the `Main` operation."
39-
isCorrect: true
40-
explanation: "Every Q# program must have an entry point, which is the `Main` operation, so the Q# compiler knows where to start the program."
41-
- content: "To run successfully, a Q# program must have an entry point and at least one allocated qubit."
42-
isCorrect: false
43-
explanation: "You can write Q# programs that don't need to perform operations on a qubit. A Q# program without a qubit allocated can run successfully."
44-
45-
- content: "Consider a quantum operation `A` that acts on a single qubit. If you want to write a Q# program that applies `A` to a qubit `q`, which of the following statements is true?"
46-
choices:
47-
- content: "You allocate a qubit using `q = Qubit();` and then apply `A` to `q` using `A(q);`."
48-
isCorrect: false
49-
explanation: "To allocate a qubit, you must use the `use` keyword, `use q = Qubit();`."
50-
- content: "You allocate a qubit using `use q = Qubit();` and then apply `A` to `q` using `A(q);`."
51-
isCorrect: true
52-
explanation: "You first allocate a qubit using `use` and then apply `A` to the qubit allocated using `A(q);`."
53-
- content: "You allocate a qubit using `use q = Qubit();` and then apply `A` to `q` using `A[q];`."
54-
isCorrect: false
55-
explanation: "To apply an operation to a qubit, you must use parentheses, `A(q);`."
1+
### YamlMime:ModuleUnit
2+
uid: learn.quantum.qsharp-create-first-quantum-development-kit.knowledge-check
3+
title: Module assessment
4+
metadata:
5+
title: Module assessment
6+
description: Check your understanding so far.
7+
author: azure-quantum-content
8+
ms.author: quantumdocwriters
9+
10+
ms.date: 06/09/2025
11+
ms.topic: unit
12+
ai-usage: ai-assisted
13+
durationInMinutes: 7
14+
content: |
15+
[!include[](includes/5-knowledge-check.md)]
16+
17+
quiz:
18+
title: Check your knowledge
19+
questions:
20+
21+
- content: 'Which of these statements is true about the random number generator that you built in this module?'
22+
choices:
23+
- content: "The quantum random number generator takes the current time from the CPU's clock as a seed to generate random numbers."
24+
isCorrect: false
25+
explanation: "The quantum random number generator doesn't use the CPU's clock to generate random numbers. A classical pseudo-random number generator would do that."
26+
- content: "The quantum random number generator creates one qubit, measures it, and the result of the measurement is a random decimal number."
27+
isCorrect: false
28+
explanation: "The result of the measurement of a qubit is a random bit, not a random decimal number. This answer doesn't describe the logic behind the random number generator that you built in this module."
29+
- content: "The quantum random number generator creates a bit string from the repetition of measurements of a qubit in superposition. Then, it takes the bit string and converts it to a decimal number."
30+
isCorrect: true
31+
explanation: "This statement describes the logic behind the random number generator that you built in this module."
32+
33+
- content: 'Which of the following structures are required for a Q# program to run successfully?'
34+
choices:
35+
- content: 'To run successfully, a Q# program must have a function.'
36+
isCorrect: false
37+
explanation: "A function isn't required in a Q# program."
38+
- content: "To run successfully, a Q# program must have an entry point, which is the `Main` operation."
39+
isCorrect: true
40+
explanation: "Every Q# program must have an entry point, which is the `Main` operation, so the Q# compiler knows where to start the program."
41+
- content: "To run successfully, a Q# program must have an entry point and at least one allocated qubit."
42+
isCorrect: false
43+
explanation: "You can write Q# programs that don't need to perform operations on a qubit. A Q# program without a qubit allocated can run successfully."
44+
45+
- content: "Consider a quantum operation `A` that acts on a single qubit. If you want to write a Q# program that applies `A` to a qubit `q`, which of the following statements is true?"
46+
choices:
47+
- content: "You allocate a qubit using `q = Qubit();` and then apply `A` to `q` using `A(q);`."
48+
isCorrect: false
49+
explanation: "To allocate a qubit, you must use the `use` keyword, `use q = Qubit();`."
50+
- content: "You allocate a qubit using `use q = Qubit();` and then apply `A` to `q` using `A(q);`."
51+
isCorrect: true
52+
explanation: "You first allocate a qubit using `use` and then apply `A` to the qubit allocated using `A(q);`."
53+
- content: "You allocate a qubit using `use q = Qubit();` and then apply `A` to `q` using `A[q];`."
54+
isCorrect: false
55+
explanation: "To apply an operation to a qubit, you must use parentheses, `A(q);`."
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.quantum.qsharp-create-first-quantum-development-kit.8-summary
3-
title: Summary
4-
metadata:
5-
title: Summary
6-
description: Summary
7-
ms.date: 10/30/2024
8-
author: azure-quantum-content
9-
ms.author: quantumdocwriters
10-
11-
ms.topic: unit
12-
durationInMinutes: 1
13-
content: |
14-
[!include[](includes/6-summary.md)]
15-
1+
### YamlMime:ModuleUnit
2+
uid: learn.quantum.qsharp-create-first-quantum-development-kit.8-summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: Summary
7+
ms.date: 06/09/2025
8+
author: azure-quantum-content
9+
ms.author: quantumdocwriters
10+
11+
ms.topic: unit
12+
durationInMinutes: 1
13+
content: |
14+
[!include[](includes/6-summary.md)]
15+

learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/1-introduction.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ After completing this module, you're able to:
1818
- Basic knowledge of classical programming concepts.
1919
- Install the latest version of [Visual Studio Code](https://code.visualstudio.com/download).
2020
- Install the latest version of the [Azure Quantum Development Kit](https://marketplace.visualstudio.com/items?itemName=quantum.qsharp-lang-vscode) extension.
21-
- You can also open [Visual Studio Code for the web](https://vscode.dev/quantum), which already includes the Quantum Development Kit extension.
22-
23-
21+
- You can also open [Visual Studio Code for the web](https://vscode.dev/quantum), which already includes the Quantum Development Kit extension.

learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/2-qsharp-structure.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
Before you start writing quantum programs, it's important to understand the structure and components of a Q# program.
33

4-
In this unit, you'll review the main components of a Q# program.
4+
In this unit, you review the main components of a Q# program.
55

66
## The `Main` operation
77

8-
Every Q# program must contain at least one operation, which is usually the `Main` operation. The `Main` operation is the entry point of your program. By default, the Q# compiler starts executing a program from the `Main()` operation. Optionally, you can use the `@EntryPoint()` attribute to specify any operation in the program as the point of execution.
8+
Every Q# program must contain at least one operation, which is usually the `Main` operation. The `Main` operation is the entry point of your program. By default, the Q# compiler starts executing a program from the `Main()` operation. Optionally, you can use the `@EntryPoint()` attribute to specify any operation in the program as the point of execution.
99

1010
For example, the following code defines an entry point operation, `MeasureOneQubit`:
1111

@@ -39,7 +39,7 @@ operation MeasureOneQubit() : Result {
3939

4040
## Quantum libraries
4141

42-
The Q# libraries contain functions and operations that you can use in quantum programs. When you call a function or operation from a library, you use the `import` directive and specify the library's namespace. For example, to use the `Message` function from the `Microsoft.Quantum.Intrinsic` namespace in the Standard quantum library, you do the following:
42+
The Q# libraries contain functions and operations that you can use in quantum programs. When you call a function or operation from a library, you use the `import` directive and specify the library's namespace. For example, to use the `Message` function from the `Microsoft.Quantum.Intrinsic` namespace in the Standard quantum library, you use the following code:
4343

4444
```qsharp
4545
// imports all functions and operations from Microsoft.Quantum.Intrinsic
@@ -79,10 +79,9 @@ To implement a measurement in the computational basis $\lbrace\ket{0},\ket{1}\rb
7979

8080
## Resetting qubits
8181

82-
In Q#, qubits must be in the $\ket{0}$ state by the time they are released. When you have finished using a qubit, you use the `Reset` operation to reset the qubit to the $\ket{0}$.
82+
In Q#, qubits must be in the $\ket{0}$ state by the time they're released. When you finish using a qubit, you use the `Reset` operation to reset the qubit to the $\ket{0}$ state.
8383

8484
```qsharp
8585
// Reset the qubit so it can be safely released.
8686
Reset(qubit);
8787
```
88-

learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/3-random-bit-generator.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ You build out your quantum random number generator in two phases. In this unit,
55
## Create the Q# program
66

77
1. Open Visual Studio Code and select **File > New Text File** to create a new file.
8-
1. Save the file as `Main.qs`. This file will contain the Q# code for your program.
8+
1. Save the file as `Main.qs`. This file contains the Q# code for your program.
99

1010
## Define the `Main` operation
1111

@@ -34,7 +34,7 @@ operation Main(): Result{
3434

3535
## Put the qubit into superposition
3636

37-
The qubit is in the $\ket{0}$ state, which isn't very useful for generating random numbers. You need to put the qubit into superposition. To do this, you apply the **Hadamard operation**, `H`, to the qubit. The Hadamard operation changes the state of the qubit and puts it into an equal superposition of $\ket{0}$ and $\ket{1}$.
37+
The qubit is in the $\ket{0}$ state, which isn't useful for generating random numbers. You need to put the qubit into superposition. To do this, you apply the **Hadamard operation**, `H`, to the qubit. The Hadamard operation changes the state of the qubit and puts it into an equal superposition of $\ket{0}$ and $\ket{1}$.
3838

3939
$$ H \ket{0} = \frac{1}{\sqrt{2}} (\ket{0} + \ket{1}) $$
4040

@@ -50,7 +50,7 @@ operation Main(): Result{
5050

5151
## Measure the qubit
5252

53-
At this point the qubit `q` has 50% chance of being measured in the |0〉 state and 50% chance of being measured in the |1〉 state. Thus, if you measure the qubit, you'll get a random bit, either 0 or 1, with equal 50% probability. The value of this bit is truly random, there's no way of knowing in advance the result of the measurement.
53+
At this point, the qubit `q` has 50% chance of being measured in the |0〉 state and 50% chance of being measured in the |1〉 state. Thus, if you measure the qubit, you get a random bit, either 0 or 1, with equal 50% probability. The value of this bit is truly random, there's no way of knowing in advance the result of the measurement.
5454

5555
To measure the qubit value, use the `M` operation and store the measurement value in the `result` variable.
5656

@@ -65,7 +65,7 @@ operation Main(): Result{
6565

6666
## Reset the qubit
6767

68-
In Q#, every qubit must be in the $\ket{0}$ state by the time they are released. You use `Reset(q)` to reset the qubit to the zero state.
68+
In Q#, every qubit must be in the $\ket{0}$ state by the time they're released. You use `Reset(q)` to reset the qubit to the zero state.
6969

7070
```qsharp
7171
operation Main(): Result{
@@ -109,7 +109,6 @@ operation Main() : Result {
109109
H(q);
110110
111111
// Measure the qubit and store the result.
112-
113112
let result = M(q);
114113
115114
// Reset qubit to the |0〉 state.
@@ -122,7 +121,7 @@ operation Main() : Result {
122121

123122
## Run the program
124123

125-
To run your program on the built-in simulator, click **Run** above the `Main` operation or press **Ctrl+F5**. Your output appears in the debug console in the terminal.
124+
To run your program on the built-in simulator, select **Run** above the `Main` operation or press **Ctrl+F5**. Your output appears in the debug console in the terminal.
126125

127126
The result is either `One` or `Zero`, which represents a truly random bit. You can run the program again to see a different result.
128127

0 commit comments

Comments
 (0)