We identify the a and b of the pattern.

In our pattern, a=p and b=q.
We use the Binomial Theorem.
(a+b)n=(n0)an+(n1)an−1b1+(n2)an−2b2+...+(nr)an−rbr+...+(nn)bn
Substitute in the values a=p, b=q and n=4.
(p+q)4=(40)p4+(41)p4−1q1+(42)p4−2q2+(43)p4−3q3+(44)q4
Simplify the exponents.
(p+q)4=(40)p4+(41)p3q+(42)p2q2+(43)pq3+(44)q4
Evaluate the coefficients. Remember, (n1)=n, (nn)=1, (n0)=1.
(p+q)4=1p4+4p3q1+2!(2)!4!p2q2+3!(4−3)!4!p1q3+1q4(p+q)4=p4+4p3q+6p2q2+4pq3+q4