z-gate-qiskit
Table of Contents
Z gate (Qiskit)
Z gate implementation using Qiskit. The Z gate applied to $\lvert 0\rangle$ is invisible at measurement (it leaves $\lvert 0\rangle$ unchanged), so this example prepares $\lvert +\rangle$ first to make the phase flip observable via interference.
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector qc = QuantumCircuit(1) qc.h(0) # |0> -> |+> qc.z(0) # |+> -> |-> print(Statevector(qc)) # Statevector([ 0.70710678+0.j, -0.70710678+0.j], dims=(2,))
z-gate-qiskit.txt ยท Last modified: by 127.0.0.1
