%matplotlib inline
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.visualization import *
from os import environ

#local environment variable to store the access token :)
token = environ.get('ibmq_token')

# Loading IBM Q account
account = IBMQ.save_account(token, overwrite=True)
provider = IBMQ.load_account()

# quasm_sim
simulator = Aer.get_backend('qasm_simulator')

# circuit on q reg with 1 qubit
circuit = QuantumCircuit(2, 2)

# hadamard gate on qbit A
circuit.h(0)

# CNOT on qbit B controlled by A
circuit.cx(0, 1)

circuit.measure([0, 1], [0, 1])

job = execute(circuit, simulator, shots=1000)

results = job.result()

counts = results.get_counts(circuit)

print(f"total count for 0 and 1 are: {counts}")

circuit.draw()

plot_histogram(counts)