I want to contruct an exam paper in latex. I need a question library written in latex. For example, there are 10 questions in it. A latex code is required that randomly selects 3 of these 10 questions, creates an exam paper and adds the answer sheet at the end. I have the following code:
\documentclass[a4paper,12pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{pythontex}
\begin{document}
\title{Exam}
\author{ }
\date{\today}
\maketitle
\section*{Sorular}
\begin{pycode}
import random
# Rastgele 3 soru seç
selected_questions = random.sample(range(1, 11), 3)
\end{pycode}
\begin{questions}
% Seçilen soruları çağır
\pyc{for q in selected_questions:}%
\pyc{ print("\\question" + str(q))}%
\end{questions}
\newpage
\section*{Cevap Anahtarı}
\begin{questions}
\question[1] b % Soru 1 için doğru cevap
\question[2] b % Soru 2 için doğru cevap
\question[3] b % Soru 3 için doğru cevap
\question[4] c % Soru 4 için doğru cevap
\question[5] b % Soru 5 için doğru cevap
\question[6] a % Soru 6 için doğru cevap
\question[7] a % Soru 7 için doğru cevap
\question[8] b % Soru 8 için doğru cevap
\question[9] b % Soru 9 için doğru cevap
\question[10] d % Soru 10 için doğru cevap
\end{questions}
\end{document}
when it runs, I get the error as Something's wrong--perhaps a missing \item. \end{questions}
I could not solve it. Could you solve it?