You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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);`."
- 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);`."
Copy file name to clipboardExpand all lines: learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/1-introduction.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,4 @@ After completing this module, you're able to:
18
18
- Basic knowledge of classical programming concepts.
19
19
- Install the latest version of [Visual Studio Code](https://code.visualstudio.com/download).
20
20
- 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.
Copy file name to clipboardExpand all lines: learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/2-qsharp-structure.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
2
2
Before you start writing quantum programs, it's important to understand the structure and components of a Q# program.
3
3
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.
5
5
6
6
## The `Main` operation
7
7
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.
9
9
10
10
For example, the following code defines an entry point operation, `MeasureOneQubit`:
11
11
@@ -39,7 +39,7 @@ operation MeasureOneQubit() : Result {
39
39
40
40
## Quantum libraries
41
41
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:
43
43
44
44
```qsharp
45
45
// 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
79
79
80
80
## Resetting qubits
81
81
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.
Copy file name to clipboardExpand all lines: learn-pr/quantum/qsharp-create-first-quantum-development-kit/includes/3-random-bit-generator.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ You build out your quantum random number generator in two phases. In this unit,
5
5
## Create the Q# program
6
6
7
7
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.
9
9
10
10
## Define the `Main` operation
11
11
@@ -34,7 +34,7 @@ operation Main(): Result{
34
34
35
35
## Put the qubit into superposition
36
36
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}$.
38
38
39
39
$$ H \ket{0} = \frac{1}{\sqrt{2}} (\ket{0} + \ket{1}) $$
40
40
@@ -50,7 +50,7 @@ operation Main(): Result{
50
50
51
51
## Measure the qubit
52
52
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.
54
54
55
55
To measure the qubit value, use the `M` operation and store the measurement value in the `result` variable.
56
56
@@ -65,7 +65,7 @@ operation Main(): Result{
65
65
66
66
## Reset the qubit
67
67
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.
69
69
70
70
```qsharp
71
71
operation Main(): Result{
@@ -109,7 +109,6 @@ operation Main() : Result {
109
109
H(q);
110
110
111
111
// Measure the qubit and store the result.
112
-
113
112
let result = M(q);
114
113
115
114
// Reset qubit to the |0〉 state.
@@ -122,7 +121,7 @@ operation Main() : Result {
122
121
123
122
## Run the program
124
123
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.
126
125
127
126
The result is either `One` or `Zero`, which represents a truly random bit. You can run the program again to see a different result.
0 commit comments