dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev)
def apply_rx_pi(state):
"""Apply an RX gate with an angle of \pi to a particular basis state.
Args:
state (int): Either 0 or 1. If 1, initialize the qubit to state |1>
before applying other operations.
Returns:
np.array[complex]: The state of the qubit after the operations.
"""
if state == 1:
qml.PauliX(wires=0)
##################
# YOUR CODE HERE #
##################
# APPLY RX(pi) AND RETURN THE STATE
return
print(apply_rx_pi(0))
print(apply_rx_pi(1))