Skip to content

Commit 3c4f7f0

Browse files
committed
review-1
1 parent 9bb22db commit 3c4f7f0

File tree

7 files changed

+132
-138
lines changed

7 files changed

+132
-138
lines changed
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: 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 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);`."

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

learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/4-random-number-generator.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In this unit, you implement the second phase of your quantum random number gener
44

55
In the previous unit, you created a random bit generator that generates a random bit by putting a qubit into superposition and measuring it.
66

7-
When 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 what you get after the measurement. But how can you use this behavior to generate larger random numbers?
7+
When 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 what you get after the measurement. But how can you use this behavior to generate larger random numbers?
88

99
Let's say you repeat the process four times, generating this sequence of binary digits:
1010

@@ -42,7 +42,7 @@ Here, you expand on the `Main.qs` file to build larger random numbers.
4242

4343
### Import the required libraries
4444

45-
First, you need to import the required namespaces from the Q# Standard library to the program. The Q# compiler loads many common functions and operations automatically, however for the complete quantum random number generator, you need some additional functions and operations from two Q# namespaces: `Microsoft.Quantum.Math`and `Microsoft.Quantum.Convert`.
45+
First, you need to import the required namespaces from the Q# Standard library to the program. The Q# compiler loads many common functions and operations automatically, however for the complete quantum random number generator, you need some more functions and operations from two Q# namespaces: `Microsoft.Quantum.Math`and `Microsoft.Quantum.Convert`.
4646

4747
Copy and paste the following `import` directives to the top of your `Main.qs` file:
4848

@@ -65,8 +65,7 @@ The `GenerateRandomBit` operation should look like this:
6565
// Set the qubit into superposition of 0 and 1 using the Hadamard
6666
H(q);
6767
68-
// Measure the qubit and store the result.
69-
68+
// Measure the qubit and store the result.
7069
let result = M(q);
7170
7271
// Reset qubit to the |0〉 state.
@@ -111,7 +110,7 @@ Let's take a moment to review the new code.
111110

112111
### Add an entry point
113112

114-
Finally, you add an entry point to the program. By default, the Q# compiler looks for a `Main` operation and starts processing there, no matter where it's located. The `Main` operation calls the `GenerateRandomNumberInRange` operation to generate a random number between 0 and a `max` number. In this example, you define the maximum value as 100.
113+
Finally, you add an entry point to the program. By default, the Q# compiler looks for a `Main` operation and starts processing there, no matter where the operation is located. The `Main` operation calls the `GenerateRandomNumberInRange` operation to generate a random number between 0 and a `max` number. In this example, you define the maximum value as 100.
115114

116115
Copy and paste the following code to your `Main.qs` file:
117116

@@ -180,12 +179,12 @@ import Microsoft.Quantum.Math.*;
180179

181180
Let's try out our new random number generator!
182181

183-
1. Before running the program, you need to set the target profile to **Unrestricted**. Select **View** > **Command Palette**, search for QIR, select **Q#: Set the Azure Quantum QIR target profile**, and then select **Q#: unrestricted**.
184-
1. To run your program, select **Run** from the list of commands above the `Main` operation or press **Ctrl+F5**. Your output will appear in the debug console.
182+
1. Before running the program, you need to set the target profile to **Unrestricted**. Select **View** > **Command Palette**, search for *QIR*, select **Q#: Set the Azure Quantum QIR target profile**, and then select **Q#: unrestricted**.
183+
1. To run your program, select **Run** from the list of commands above the `Main` operation or press **Ctrl+F5**. Your output displays in the debug console.
185184
1. Run the program again to see a different result.
186185

187186
> [!NOTE]
188-
> If the target profile is not set to **Unrestricted**, you will get an error when you run the program.
187+
> If the target profile isn't set to **Unrestricted**, you get an error when you run the program.
189188
190189
Congratulations! Now you know how to combine classical logic with Q# to create a quantum random number generator.
191190

learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/6-summary.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ The Quantum Development Kit provides you with everything you need to start writi
44

55
In this module, we covered a lot. Here are a few key concepts to keep in mind:
66

7-
* A Q# program must have an entry point, which is the `Main` operation.
8-
* In Q#, you allocate a qubit by using the `use` keyword and the `Qubit` type. The qubit is always in the $\ket{0}$ state.
9-
* Superposition is a quantum phenomenon where a qubit is in a combination of both zero and one states. If a qubit is in the $\ket{0}$ state, you can put it into superposition by using the `H` operation.
10-
* In Q#, you use the `M` operation to measure qubits in the Z-basis. When measured, a qubit goes from being in superposition to one of the classical states.
11-
* You can combine classical code with quantum code. This combination enables you to perform quantum computations and work with the results, all in the same program.
7+
- A Q# program must have an entry point, which is the `Main` operation.
8+
- In Q#, you allocate a qubit by using the `use` keyword and the `Qubit` type. The qubit is always in the $\ket{0}$ state.
9+
- Superposition is a quantum phenomenon where a qubit is in a combination of both zero and one states. If a qubit is in the $\ket{0}$ state, you can put it into superposition by using the `H` operation.
10+
- In Q#, you use the `M` operation to measure qubits in the Z-basis. When measured, a qubit goes from being in superposition to one of the classical states.
11+
- You can combine classical code with quantum code. This combination enables you to perform quantum computations and work with the results, all in the same program.
1212

1313
## Next steps
1414

15-
The Quantum Development Kit includes a set of built-in Q# samples that you can use to learn more about Q# and quantum computing. To view the samples, open a blank Q# file in Visual Studio Code and type `sample`, then select the sample you want to view from the list of options. For example, you can find the Q# code in unit 2 under "Random Bit sample".
15+
The Quantum Development Kit includes a set of built-in Q# samples that you can use to learn more about Q# and quantum computing. To view the samples, open a blank Q# file in Visual Studio Code and type `sample`, then select the sample you want to view from the list of options. For example, you can find the Q# code we used in unit 2 by selecting *Random Bit sample*.
1616

1717
## Learn more
1818

19-
* Explore the [Azure Quantum documentation](/quantum/?azure-portal=true).
20-
* Learn quantum computing with the [Quantum Katas](https://quantum.microsoft.com/tools/quantum-katas).
21-
19+
- Explore the [Azure Quantum documentation](/quantum/?azure-portal=true).
20+
- Learn quantum computing with the [Quantum Katas](https://quantum.microsoft.com/tools/quantum-katas).

0 commit comments

Comments
 (0)