Skip to content

Commit e0bb0bd

Browse files
committed
Add First Quantum Qiskit Code Tutorial
1 parent 2b5b2c6 commit e0bb0bd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

quantum/q1.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import qiskit as q
2+
3+
"""
4+
Build a simple bare-minimum quantum
5+
circuit that starts with a single qubit
6+
(by default in state 0), runs the experiment
7+
1000 times, and finally prints the total
8+
count of the states finally observed.
9+
"""
10+
11+
# Use Aer's qasm_simulator
12+
simulator = q.Aer.get_backend('qasm_simulator')
13+
14+
# Create a Quantum Circuit acting on the q register
15+
circuit = q.QuantumCircuit(1, 1)
16+
circuit.h(0)
17+
18+
# Map the quantum measurement to the classical bits
19+
circuit.measure([0], [0])
20+
21+
# Execute the circuit on the qasm simulator
22+
job = q.execute(circuit, simulator, shots=1000)
23+
24+
# Grab results from the job
25+
result = job.result()
26+
27+
# Returns counts
28+
counts = result.get_counts(circuit)
29+
print("\nTotal count for varopis staes are:", counts)

0 commit comments

Comments
 (0)