%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
# Loading your IBM Q account(s)
provider = IBMQ.load_account()

# Create a quantum circuit containing three quantum bits, and three classical bits to hold measurement results.
qc = QuantumCircuit(3, 3)
qc.h(0)
qc.h(1)
qc.h(2)
qc.measure(range(3),range(3))


qc.draw()

def answer(result):
    for key in result.keys():
        state = key
    print('The Quantum 8-ball says:')
    if state == '000':
        print('It is certain.')
    elif state == '001':
        print('Without a doubt.')
    elif state == '010':
        print('Yes - definitely.')
    elif state == '011':
        print('Most likely.')
    elif state == '100':
        print("Don't count on it.")
    elif state == '101':
        print('My reply is no.')
    elif state == '110':
        print('Very doubtful.')
    else:
        print('Concentrate and ask again.')

job = execute(qc, backend=Aer.get_backend('qasm_simulator'), shots=1)
counts = job.result().get_counts(qc)
answer(counts)

from qiskit.quantum_info import Statevector
qc = QuantumCircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)

sv = Statevector.from_instruction(qc)
counts = sv.sample_counts(shots = 1)
answer(counts)