Given the quadratic functionf(x)=x^2+(3k+1)x+k^2,find the value(s)of kif f(x)is a perfect square

If x^2+(3k+1)x+k^2 is a perfect square, then

3k+1 = 2k
because (x+a)^2 = x^2 + 2ax + a^2
so, k=-1, and your polynomial is

x^2 -2x + 1 = (x-1)^2