From the course: Quantum Computing Fundamentals

Unlock the full course today

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

Hadamard gate with Qiskit

Hadamard gate with Qiskit

- Let's explore the Hadamard gate in action with qiskit. I've already imported qiskit and the visualization tools we'll be using at the top of the notebook, and in the second cell I've initialized a quantum circuit with one qubit and one classical bit. However, as we can see from the circuit diagram it does not perform a measurement on that qubit. The third and fourth cells simulate the circuit's state vector and then print that out along with its block sphere representation. After that, I add a measurement to the end of that circuit and redraw its diagram. Then finally, I use the chasm simulator to simulate the circuit and plot a histogram of outcomes. Since it's just a single qubit in the initial zero state we always get zero as the measured output. Now let's add the Hadamard gate to that qubit by calling circuit.h and then passing in the index value zero. I'll click the run all button to rerun this entire notebook…

Contents