Discrete NOT gate may be realized by using transistors.
The inputs represented as X may be either 0V or +5V correspondingly.
The output is represented by Z.
When the input X = 0V, then the transistor Q1 will be reverse biased and therefore it remains OFF.
As a result no current flows through the resistor and thereby there will not be any voltage drop across the resistor.
As a result, the output voltage Z corresponds to +5V. When the input X= +5V, transistor Q1 is ON and the output voltage Z=V ce(sat) corresponds to 0V.
Enjoy...😎