Here is an approach using the sagetex package, found here. I've put all the output on one page for illustrative purposes. Adding \newpage in the appropriate places will give the effect you've asked for:
\documentclass{article}
\usepackage{sagetex}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage{amsmath}
\lhead{Name:}
\chead{Function Table}
\rhead{Date:}
\lfoot{}
%\cfoot{\thepage}
\rfoot{}
\pagestyle{fancy}
\begin{document}
\begin{sagesilent}
def Qtable(n,f,v1,v2,v3,v4,v5):
f(x) = f
output = r""
output += r"\noindent\textbf{Question $%s$}\\\\"%(n)
output += r"\begin{tabular}{|c|c|c|c|c|c|}"
output += r"\hline"
output += r"$x$ & $%s$ & $%s$ & $%s$ & $%s$ & $%s$\\"%(v1,v2,v3,v4,v5)
output += r"\hline"
output += r"$f(x)=%s$ & & & & & \\"%(f(x))
output += r"\hline"
output += r"\end{tabular}"
return output
def Atable(n,f,v1,v2,v3,v4,v5):
f(x) = f
output = r""
output += r"\textbf{Question $%s$ solution}\\\\"%(n)
output += r"\begin{tabular}{|c|c|c|c|c|c|}"
output += r"\hline"
output += r"$x$ & $%s$ & $%s$ & $%s$ & $%s$ & $%s$\\"%(v1,v2,v3,v4,v5)
output += r"\hline"
output += r"$f(x)=%s$ & $%s$ & $%s$ & $%s$ & $%s$ & $%s$\\"%(f(x),f(v1),f(v2),f(v3),f(v4),f(v5))
output += r"\hline"
output += r"\end{tabular}"
return output
\end{sagesilent}
\begin{sagesilent}
Q1 = Qtable(1,x+1,-3,-2,0,1,2)
Q1A = Atable(1,x+1,-3,-2,0,1,2)
\end{sagesilent}
\sagestr{Q1}\\\\
\sagestr{Q1A}\\\\
\begin{sagesilent}
Q2 = Qtable(2,x^2-2*x+1,-4,-1,0,3,12)
Q2A = Atable(2,x^2-2*x+1,-4,-1,0,3,12)
\end{sagesilent}
\sagestr{Q2}\\\\
\sagestr{Q2A}
\end{document}
The output running in Cocalc is:

Remember, sagetex is part of the LaTeX distribution but it relies on the computer algebra system SAGE which is not. You either need SAGE installed locally on your computer or you use the free Cocalc to get access to SAGE over the internet. The compilation using sagetex is a 3 step process: first LaTeX runs, then SAGE runs, then LaTeX runs again. It helps to think that the first run of LaTeX will create a blank box for the SAGE result, then SAGE calculates results, and the final LaTeX run fills in the box. The program won't run if the SAGE calculation is needed in the LaTeX compilation. To get finesse these problems the LaTeX code is created
by SAGE. A Python function Qtable (for question table) will create the LaTeX code for the blank table while Atable (for answer table) will create the table filled in correctly. The third run through the process, running LaTeX, is now compiling a document that is longer as it contains LaTeX code that SAGE created.
The easiest way to get started with SAGE and sagetex is by signing up for a free Cocalc account