1
1
#!/usr/bin/env python3
2
2
"""
3
- Build a simple bare-minimum quantum circuit that starts with a single
4
- qubit (by default, in state 0) and inverts it. Run the experiment 1000
3
+ Build a simple bare-minimum quantum circuit that starts with a single
4
+ qubit (by default, in state 0) and inverts it. Run the experiment 1000
5
5
times and print the total count of the states finally observed.
6
6
Qiskit Docs: https://qiskit.org/documentation/getting_started.html
7
7
"""
11
11
12
12
def single_qubit_measure (qubits : int , classical_bits : int ) -> q .result .counts .Counts :
13
13
"""
14
- >>> single_qubit_measure(1, 1 )
14
+ >>> single_qubit_measure(2, 2 )
15
15
{'11': 1000}
16
+ >>> single_qubit_measure(4, 4)
17
+ {'0011': 1000}
16
18
"""
17
19
# Use Aer's qasm_simulator
18
- simulator = q .Aer .get_backend (' qasm_simulator' )
20
+ simulator = q .Aer .get_backend (" qasm_simulator" )
19
21
20
22
# Create a Quantum Circuit acting on the q register
21
23
circuit = q .QuantumCircuit (qubits , classical_bits )
@@ -34,6 +36,6 @@ def single_qubit_measure(qubits: int, classical_bits: int) -> q.result.counts.Co
34
36
return job .result ().get_counts (circuit )
35
37
36
38
37
- if __name__ == ' __main__' :
39
+ if __name__ == " __main__" :
38
40
counts = single_qubit_measure (2 , 2 )
39
- print (f' Total count for various states are: { counts } ' )
41
+ print (f" Total count for various states are: { counts } " )
0 commit comments