Logic gates and logic circuits
The best way to do this is to analyze each case separately.  This gate has two input signals, so only four combinations to analyze.  For each case write down the inputs and the resulting output.  After the four cases, you have a truth table, which you say you already understand.

Here is the case with both inputs 0:



Both transistors are obviously off, so the pullup drives the output high.

Now do the (1,0) inputs case:



The bottom transistor is obviously off, so again the outut can only be high.

Case (0,1):



Case (1,1):



From these four cases you get the truth table:


  In1  In2  Out
  ---  ---  ---
    0    0    1
    1    0    1
    0    1    1
    1    1    0

which is the NAND function.