From the course: Quantum Computing Fundamentals

Unlock the full course today

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

Controlled-NOT (CNOT) gate with Qiskit

Controlled-NOT (CNOT) gate with Qiskit

From the course: Quantum Computing Fundamentals

Controlled-NOT (CNOT) gate with Qiskit

- [Instructor] To demonstrate the controlled-NOT gate with Qiskit, I've initialized a simple quantum circuit with two qubits. By default, these two new qubits will be initialized to the 0-0 state, and we can see that below on the simulated block spheres. Now, to apply a C-NOT gate, I'll type circuit.cnot. And then for the first parameter, I'll provide the index of the qubit to use as the control, which will be qubit zero. And the second parameter is the target qubit, which will be one. I'll click the run all button to rerun this notebook. And we can see the updated circuit diagram, which now includes a C-NOT gate, with the first qubit as the control and the second qubit as its target. However, if we look at the block spheres, they're still in the same 0-0 state. Since the control qubit was zero, nothing happened. So, let's insert an X gate to flip that control to one just before the C-NOT. I'll press Shift + Enter twice…

Contents