import qiskit

qiskit.__qiskit_version__

from qiskit import IBMQ

IBMQ.save_account('46fd3c15ef48cd5f5d6e4a8ae48748af512d2a57b1647282d61d7e98fda97a54d4be4ab8ff433fccd6613f9e30b3819a1aef9d6262f4980804cb2cd3952f7850')

IBMQ.load_account()

from qiskit import *

qr = QuantumRegister(2)

cr = ClassicalRegister(2)

circuit = QuantumCircuit(qr,cr)

%matplotlib inline

circuit.draw()

circuit.h(qr[0]) #hadamard gate
circuit.draw(output = 'mpl')

circuit.cx(qr[0],qr[1]) #controlled X gate
circuit.draw(output = 'mpl')

circuit.measure(qr,cr)
circuit.draw(output = 'mpl')

#setting up simulator

simulator = Aer.get_backend('qasm_simulator')

result = execute(circuit, backend = simulator).result()

from qiskit.tools.visualization import plot_histogram

    plot_histogram(result.get_counts(circuit))

provider = IBMQ.get_provider('ibm-q')

# Get a list of available backends
backends = provider.backends()

# Print the names of available backends
    print("Available Backends:", [backend.name() for backend in backends])

qcomp = provider.get_backend('ibm_osaka')

job = execute(circuit, backend = qcomp)

from qiskit.tools.monitor import job_monitor

job_monitor(job)

results = job.result()

plot_histogram(results.get_counts(circuit))

