Skip to content

Commit 52d4a43

Browse files
committed
Add Qiskit Quantum NOT Gate Example Code
1 parent a9fa2d9 commit 52d4a43

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: quantum/q1.py renamed to quantum/single_qubit_not_gate.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
"""
33
Build a simple bare-minimum quantum circuit that starts with a single
4-
qubit (by default, in state 0), runs the experiment 1000 times, and
5-
finally prints the total count of the states finally observed.
4+
qubit (by default, in state 0) and inverts it. Run the experiment 1000
5+
times and print the total count of the states finally observed.
66
Qiskit Docs: https://qiskit.org/documentation/getting_started.html
77
"""
88

@@ -13,14 +13,17 @@
1313
def single_qubit_measure() -> q.result.counts.Counts:
1414
"""
1515
>>> single_qubit_measure()
16-
{'0': 1000}
16+
{'1': 1000}
1717
"""
1818
# Use Aer's qasm_simulator
1919
simulator = q.Aer.get_backend('qasm_simulator')
2020

2121
# Create a Quantum Circuit acting on the q register
2222
circuit = q.QuantumCircuit(1, 1)
2323

24+
# Apply X (NOT) Gate to Qubit 0
25+
circuit.x(0)
26+
2427
# Map the quantum measurement to the classical bits
2528
circuit.measure([0], [0])
2629

0 commit comments

Comments
 (0)