# import all necessary objects and methods for quantum circuits
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer

# define a quantum register with one qubit
qreg3 =  QuantumRegister(1)

# define a classical register with one bit
# it stores the measurement result of the quantum part
creg3 = ClassicalRegister(1)

# define our quantum circuit
mycircuit3 = QuantumCircuit(qreg3,creg3)

# apply x-gate to the first qubit
mycircuit3.x(qreg3[0])

# apply h-gate (Hadamard: quantum coin-flipping) to the first qubit
mycircuit3.h(qreg3[0])

# measure the first qubit, and store the result in the first classical bit
mycircuit3.measure(qreg3,creg3)

print("Everything looks fine, let's continue ...")

# draw the circuit by using matplotlib

mycircuit3.draw(output='mpl',reverse_bits=True)
# reexecute me if you DO NOT see the circuit diagram

# execute the circuit and read the results
job = execute(mycircuit3,Aer.get_backend('qasm_simulator'),shots=10000)

counts3 = job.result().get_counts(mycircuit3)
print(counts3)

# import all necessary objects and methods for quantum circuits
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer

# define a quantum register with one qubit
qreg4 =  QuantumRegister(1)

# define a classical register with one bit
# it stores the measurement result of the quantum part
creg4 = ClassicalRegister(1)

# define our quantum circuit
mycircuit4 = QuantumCircuit(qreg4,creg4)

# apply x-gate to the first qubit
mycircuit4.x(qreg4[0])

# apply h-gate (Hadamard: quantum coin-flipping) to the first qubit twice
mycircuit4.h(qreg4[0])
mycircuit4.h(qreg4[0])

# measure the first qubit, and store the result in the first classical bit
mycircuit4.measure(qreg4,creg4)

print("Everything looks fine, let's continue ...")

# draw the circuit by using matplotlib

mycircuit4.draw(output='mpl',reverse_bits=True)
# reexecute me if you DO NOT see the circuit diagram

# execute the circuit and read the results
job = execute(mycircuit4,Aer.get_backend('qasm_simulator'),shots=10000)

counts4 = job.result().get_counts(mycircuit4)
print(counts4)

