from qiskit import * # this means that from the qiskit package
                     # import ALL functionality(*)
    
# we also want to see our results in insightful ways through graphs! 
from qiskit.visualization import * # bloch sphere graphs, bar graphs for measurements 

# We also need to import the simulators that we will use to make measurements

S_simulator=Aer.backends(name='statevector_simulator')[0] # allows you to simulate statevectors
M_simulator=Aer.backends(name='qasm_simulator')[0] # allows you to simulate measurements

# X gate on |0> 

# make the circuit with one qubit and one classical bit
qc=QuantumCircuit(1,1)

# print out initial state to confirm that something happens when we use our gate! 
initial_state=execute(qc, S_simulator).result().get_statevector()
print('Initial state: ', initial_state)

# use the x gate on the first qubit
qc.x(0)

# print out results! 
state_after_gate= execute(qc, S_simulator).result().get_statevector()
print('state after X gate: ', state_after_gate)

# X gate on |1> 

# make the circuit with one qubit and one classical bit
qc=QuantumCircuit(1,1)

# Initialize circuit to |1> 
one = [0,1]
qc.initialize(one, 0)

# print out initial state to confirm that something happens when we use our gate! 
initial_state=execute(qc, S_simulator).result().get_statevector()
print('Initial state: ', initial_state)

# use the x gate on the first qubit
qc.x(0)

# print out results! 
state_after_gate= execute(qc, S_simulator).result().get_statevector()
print('state after X gate: ', state_after_gate)

# Y gate on |0> 

# make the circuit with one qubit and one classical bit
qc=QuantumCircuit(1,1)

# print out initial state to confirm that something happens when we use our gate! 
initial_state=execute(qc, S_simulator).result().get_statevector()
print('Initial state: ', initial_state)

# use the x gate on the first qubit
qc.y(0)

# print out results! 
state_after_gate= execute(qc, S_simulator).result().get_statevector()
print('state after X gate: ', state_after_gate)

# Y gate on |1> 

# make the circuit with one qubit and one classical bit
qc=QuantumCircuit(1,1)

# Initialize circuit to |1> 
one = [0,1]
qc.initialize(one, 0)

# print out initial state to confirm that something happens when we use our gate! 
initial_state=execute(qc, S_simulator).result().get_statevector()
print('Initial state: ', initial_state)

# use the x gate on the first qubit
qc.y(0)

# print out results! 
state_after_gate= execute(qc, S_simulator).result().get_statevector()
print('state after X gate: ', state_after_gate)

# Z gate on |0> 

# make the circuit with one qubit and one classical bit
qc=QuantumCircuit(1,1)

# print out initial state to confirm that something happens when we use our gate! 
initial_state=execute(qc, S_simulator).result().get_statevector()
print('Initial state: ', initial_state)

# use the x gate on the first qubit
qc.z(0)

# print out results! 
state_after_gate= execute(qc, S_simulator).result().get_statevector()
print('state after Z gate: ', state_after_gate)

# Z gate on |1> 

# make the circuit with one qubit and one classical bit
qc=QuantumCircuit(1,1)

# Initialize circuit to |1> 
one = [0,1]
qc.initialize(one, 0)

# print out initial state to confirm that something happens when we use our gate! 
initial_state=execute(qc, S_simulator).result().get_statevector()
print('Initial state: ', initial_state)

# use the x gate on the first qubit
qc.z(0)

# print out results! 
state_after_gate= execute(qc, S_simulator).result().get_statevector()
print('state after Z gate: ', state_after_gate)