-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_quantum_circuit.py
More file actions
35 lines (26 loc) · 1.06 KB
/
python_quantum_circuit.py
File metadata and controls
35 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -----------------------------------------------------------------------
# python_quantum_circuit.py
# Version: 1.0
# Author: Vell Void
# GitHub: https://github.com/VellVoid
# Twitter: https://twitter.com/VellVoid
# -----------------------------------------------------------------------
from qiskit import QuantumCircuit, transpile, assemble, Aer, execute
from qiskit.visualization import plot_bloch_multivector, plot_histogram
# Create a Quantum Circuit acting on a quantum register of one qubit
circuit = QuantumCircuit(1, 1)
# Add a H gate on qubit 0, putting this qubit in superposition.
circuit.h(0)
# Add a Measure gate to see the state.
circuit.measure([0], [0])
# Use Aer's qasm_simulator
simulator = Aer.get_backend('qasm_simulator')
# Execute the circuit on the qasm simulator
job = execute(circuit, simulator, shots=1000)
# Grab the results from the job
result = job.result()
# Get the counts (how many times we got 0 and how many times we got 1)
counts = result.get_counts(circuit)
print("\nTotal count for 0 and 1 are:",counts)
# Draw the circuit
print(circuit)