# Creating quantum circuits
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister
from qiskit import execute, Aer
from qiskit.tools.visualization import circuit_drawer, plot_histogram


qr =  QuantumRegister(1)
cr = ClassicalRegister(1)
qc = QuantumCircuit(qr, cr)

# Apply a single H gate
qc.h(qr)
qc.measure(qr, cr)
circuit_drawer(qc)

# Create a backend object
local_simulator = Aer.get_backend('qasm_simulator')

# Run the circuit
job = execute(qc, backend=local_simulator, shots=100)
result = job.result()
counts = result.get_counts()
plot_histogram(counts)
print(counts)

qc2 = QuantumCircuit(qr, cr)
qc2.h(qr)
qc2.h(qr)
qc2.measure(qr, cr)
circuit_drawer(qc2)

# Run the circuit with 2 H gates applied in succession
job = execute(qc2, backend=local_simulator, shots=100)
result = job.result()
counts = result.get_counts()
plot_histogram(counts)
print(counts)