Skip to content

Commit 78c281b

Browse files
committed
Address Review Comments
Signed-off-by: Abhishek Jaisingh <[email protected]>
1 parent 222fa19 commit 78c281b

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

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

+13-18
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,34 @@
66
Qiskit Docs: https://qiskit.org/documentation/getting_started.html
77
"""
88

9-
109
import qiskit as q
1110

1211

13-
def single_qubit_measure() -> q.result.counts.Counts:
12+
def single_qubit_measure(qubits: int, classical_bits: int) -> q.result.counts.Counts:
1413
"""
15-
>>> single_qubit_measure()
16-
{'1': 1000}
14+
>>> single_qubit_measure(1, 1)
15+
{'11': 1000}
1716
"""
1817
# Use Aer's qasm_simulator
19-
simulator = q.Aer.get_backend("qasm_simulator")
18+
simulator = q.Aer.get_backend('qasm_simulator')
2019

2120
# Create a Quantum Circuit acting on the q register
22-
circuit = q.QuantumCircuit(1, 1)
21+
circuit = q.QuantumCircuit(qubits, classical_bits)
2322

24-
# Apply X (NOT) Gate to Qubit 0
23+
# Apply X (NOT) Gate to Qubits 0 & 1
2524
circuit.x(0)
25+
circuit.x(1)
2626

2727
# Map the quantum measurement to the classical bits
28-
circuit.measure([0], [0])
28+
circuit.measure([0, 1], [0, 1])
2929

3030
# Execute the circuit on the qasm simulator
3131
job = q.execute(circuit, simulator, shots=1000)
3232

33-
# Grab results from the job
34-
result = job.result()
35-
36-
# Get the histogram data of an experiment.
37-
counts = result.get_counts(circuit)
38-
39-
return counts
33+
# Return the histogram data of the results of the experiment.
34+
return job.result().get_counts(circuit)
4035

4136

42-
if __name__ == "__main__":
43-
counts = single_qubit_measure()
44-
print("Total count for various states are:", counts)
37+
if __name__ == '__main__':
38+
counts = single_qubit_measure(2, 2)
39+
print(f'Total count for various states are: {counts}')

0 commit comments

Comments
 (0)