-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelloQiskit.py
More file actions
40 lines (30 loc) · 1.1 KB
/
HelloQiskit.py
File metadata and controls
40 lines (30 loc) · 1.1 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
36
37
38
39
40
import matplotlib.pyplot as plt
from qiskit import *
from qiskit.tools.visualization import plot_histogram, circuit_drawer, plot_bloch_multivector
from qiskit.tools.monitor import job_monitor
#Please, fill this with your own token, which is supposed to be secret
IBMQ.save_account('######', overwrite=True)
circuit = QuantumCircuit(1,1)
circuit.h(0)
circuit_drawer(circuit, filename='circuit.png', output='mpl')
simulator = Aer.get_backend('statevector_simulator')
result = execute(circuit, backend=simulator).result()
statevector = result.get_statevector()
plot_bloch_multivector(statevector)
plt.savefig('Bloch_Sphere.png')
plt.clf()
circuit.measure(0,0)
simulator = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=simulator).result()
plot_histogram(result.get_counts(circuit))
plt.savefig('Simulator_counts.png')
plt.clf()
#IBMQ.load_account()
#provider = IBMQ.get_provider('ibm-q')
#qcomp = provider.get_backend('ibmq_essex')
#job = execute(circuit, backend=qcomp)
#job_monitor(job)
#result=job.result()
#plot_histogram(result.get_counts(circuit))
#plt.savefig('Essex_counts.png')
#plt.clf()