Still be confused in how to add a slack variable

Can you take my code for example? Why does the optimal value become NaN sometimes? Because it seems that you just said something information about slack variable,but i still don’t know how to use it in my code