Important: qubit-ordering convention. In PennyLane, qubits are indexed
numerically from left to right. Therefore, a state such as 0
and 2
) are in state
A different convention, where qubit 0
is the rightmost qubit in the ket, is
used in a number of other quantum computing software frameworks and
resources. Always check the qubit ordering when you start using a new software
library!
For this codercise, you will write a circuit in PennyLane that accepts an integer
value, then prepares and returns the corresponding computational basis state
vector
You will find the numpy
function np.binary_repr
helpful for this challenge.
There are two ways to solve this challenge. The first is to manipulate the individual qubits based on the bit values. The second is to use a built-in state preparation template. Check out the PennyLane template library and see if there are any predefined functions that will help you.
To interact with codercises, please switch to a larger screen size.
Learning Objectives: