The Z gate rotates the qubit it acts on by 180 degrees about the z axis. Since the qubits |"0"> and |"1"> are already aligned along the z axis, a rotation by 180 degrees with the Z gate won't change them. Using the Z gate on |"+"> or |"-">, we would see an effect, because these qubits aren't aligned with the z axis. However, the effect is the same as applying the Y gate on |"+"> or |"-">, as these qubits are aligned with the x axis whether we rotate around the y axis or the z axis; either way, we will flip |"+"> to |"-"> and |"-"> to |"+">.
To see the Z gate having an effect on a qubit, and a different effect from the Y gate, we will consider it operating on the qubit, which as previously plotted aligns the qubit with the y axis as visualized with the plot_bloch(clockwisearrow_qubit) statement:
Since is already aligned with the y axis, rotating it 180 degrees about the y axis with the Y gate will have no effect. In words/algebra, that means that Y = . However, rotating by 180 degrees about the z axis will have an effect, as we can see from visualizing with the plot_bloch(Z*clockwisearrow_qubit) statement:
Here, has been flipped by 180 degrees and is now equal to . In words/algebra, that means that . If we operated the Z gate on , we would see .
The Z gate acts as a NOT gate with respect to and , flipping to and to .