From the course: Quantum Computing Fundamentals

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Solution: Binary numbers

Solution: Binary numbers

(upbeat music) - Let's talk through how we approach the challenge to encode a binary value into a set of qubits. Since Qiskit initializes all qubits in the cat 0 basis state, we'll need to use either the Pauli-X or Pauli-Y gates to flip some of those bits to represent the desired value. The Pauli-Z gate is not going to be of any use for this challenge, so we can forget about it. To determine which bits need to be flipped, we looked at the location of the ones in the desired end state. The first, third, and fourth qubits in the cat 1101 needs to be flipped, which corresponds to the index values 0, 2, and 3, because Python uses zero indexing. To build the code, I started by initializing a new quantum circuit with four qubits and assigning it the variable name circuit. (keyboard clicking) Next, I added the Pauli-X gate to the circuit, and called it on the three qubit indexes I identified: 0, 2, and 3. (keyboard…

Contents