Solution (source code)

= Solution

Writing the given <bases> as $(u_1,\ldots,u_p)$ and $(v_1,\ldots,v_q)$, a <basis> of the <Cartesian product> with its componentwise <vector space> operations is
$$
\boxed{\bigl((u_1,0),\ldots,(u_p,0),(0,v_1),\ldots,(0,v_q)\bigr).}
$$
This is the <direct sum basis>. Therefore \b[$\dim(W_1\times W_2)=p+q=\dim W_1+\dim W_2$]. The construction includes zero-dimensional factors, whose corresponding portion of the <basis> is empty.