from qiskit import IBMQ, BasicAer, QuantumCircuit, execute
import qiskit.tools.jupyter 
from qiskit.tools import job_monitor
from qiskit.visualization import plot_gate_map, plot_error_map
from qiskit.providers.ibmq import least_busy

provider = IBMQ.load_account()

%qiskit_version_table

print(qiskit.__qiskit_version__)

## qiskit terra version

print(qiskit.__version__) 

%qiskit_copyright

BasicAer.backends()

# It works also for other simulators such as: Aer.backends()

%qiskit_backend_overview

backend = least_busy(provider.backends(filters=lambda b: b.configuration().n_qubits >= 3 and
                                   not b.configuration().simulator and b.status().operational==True))

print(backend)

# Plot gate map
plot_gate_map(backend, plot_directed = True)

# Plot error map
plot_error_map(backend)

qc_open = QuantumCircuit.from_qasm_file('myfile.qasm')
qc_open.draw('mpl')

temp = QuantumCircuit(2)
temp.h(0)
temp.h(1)
temp.s(0)
temp.s(1)

qasm_str = temp.qasm() #returning a qasm string, THIS SIMPLE
qasm_str

qc_open1 = QuantumCircuit.from_qasm_str(qasm_str)
qc_open1 == qc_open

%qiskit_job_watcher

backend_sim = BasicAer.get_backend('qasm_simulator')
job = execute(qc_open1, backend_sim, shots = 1024)

job_monitor(job)

# or 

job.status()

