% !TEX TS-program = pythonxelatex


%%% a minimal example of working with pythontex in AMC
%%% to generate questions with varying numbers
%%%
%%% to typeset, run xelatex, then pythontex, then xelatex again (or use a script that calls them in succession)
%%% the first line above is used by TeXShop to use such a script or "engine" and is ignored by latex
%%% 
%%% (pdflatex or lualatex would work too)

\documentclass[a4paper]{article}

\usepackage{pythontex}
\usepackage{automultiplechoice}

\begin{document}

\element{test}{
\begin{question}{q}
\pyc{import random; a=random.choice([1,2,3]); b=random.choice([1,2,3])}
What is the value of $\py{a}+\py{b}$? 
\begin{choices}
  \correctchoice{$\py{a+b}$}
  \wrongchoice{$\py{a+b+1}$}
   \wrongchoice{$\py{a+b-1}$}
\end{choices}

\end{question}

}


\onecopy{7}{

\noindent{\bf TEST}

\insertgroup{test}
\clearpage

}

\end{document}
