Formula relating Euler characteristics $\chi(A)$, $\chi(X)$, $\chi(Y)$, $\chi(Y \cup_f X)$ when $X$ and $Y$ are finite. This is a followup to my question here.
Let $A$ be the subcomplex of a CW complex $X$, let $Y$ be a CW complex, let $f: A \to Y$ be a cellular map, and let $Y \cup_f X$ be the pushout of $f$ and the inclusion $A \to X$. Is there a formula relating the Euler characteristics $\chi(A)$, $\chi(X)$, $\chi(Y)$, and $\chi(Y \cup_f X)$ when $X$ and $Y$ are finite?

Indeed, there is. Let $Z=Y \cup_f X$ be the pushout of the diagram $X\leftarrow A\rightarrow Y$. I claim that $$\chi(Z)=\chi(X)+\chi(Y)-\chi(A).$$
To see this, let us first recall the following general fact

For any chain complex $C_*$ it holds that $$\sum_n (-1)^n \text{rank }C_n = \sum_n (-1)^n \text{rank }H_n(C_*).$$

This is rather simple to prove and you can read about it, for example, in Hatcher's proof of Theorem 2.44.
Now consider the Mayer-Vietoris sequence corresponding to the above pushout:
$$\cdots \underbrace{H_1(Z)}_{C_3}\to \underbrace{H_0(A)}_{C_2}\to \underbrace{H_0(X)\oplus H_0(Y)}_{C_1}\to \underbrace{H_0(Z)}_{C_0}\to 0 $$
Any long exact sequence may trivially be considered a chain complex, so let's define $C_i$ as indicated above. Then since the homology of an exact chain complex vanishes, we have $\text{rank }H_n(C_*)=0$ for all $n$. Hence, we get
$$\begin{eqnarray}0&=&\sum_n (-1)^n \text{rank }H_n(C_*)
\\&\stackrel{\text{General fact}}{=}& \sum_n(-1)^n\text{rank }C_n
\\&\stackrel{\text{Def. of }C_i}{=}&\text{rank }H_0(Z) - (\text{rank }H_0(X) +\text{rank }H_0(Y)) + \text{rank }H_0(A) -\text{rank }H_1(Z)+\cdots
\\&\stackrel{\text{Euler-Poincare formula}}{=}&\chi(Z) - (\chi(X)+\chi(Y)) + \chi(A)
\end{eqnarray}$$
which implies the claim.
