%%AMC:preprocess_command=texpytex.sh
%%AMC:latex_engine=pdflatex
% https://tex.stackexchange.com/questions/396862/how-can-i-pass-a-pythontex-variable-to-latex
% https://ctan.crest.fr/tex-archive/macros/latex/contrib/pythontex/pythontex.pdf
\documentclass{article}
\usepackage{automultiplechoice}
\usepackage{pythontex}
\usepackage{pgfplots}



\begin{pycode}
import numpy as np
\end{pycode}

\begin{document}

\def\pyA{
\pyc{a=np.random.randint(10)}
Essai de saisie de valeur 
  \pys{!{a}}
  \pys{\AMCnumericChoices{!{a}}{digits=1,decimals=0,sign=false,scoreexact=1,scorewrong=-0.5}}
}

\element{essai}{
  \begin{questionmultx}{python-a}
    \pyA
  \end{questionmultx}
} % Fin de element "essai"

\exemplaire{10}{
  \melangegroupe{essai}
  \restituegroupe{essai}
} % Fin de exemplaire

\end{document}
