What is wrong with the following program that prints all divisors?

\vspace{0.5cm}

\begin{Verbatim}[xleftmargin=6mm]
\textbf{def} divisors(n):
  \textbf{for} d \textbf{in} range(1,\red{n}):
    \textbf{if} n % d == 0:
      print(d)
\end{Verbatim}

\vspace{0.5cm}
		
Answer: \texttt{range(1,n)} only generates values up to \texttt{n-1}, so \texttt{n} is not printed.
Instead, \texttt{range(1,n+1)} should be used.

\vspace{1cm}

An experienced teacher can spot such errors easily, without having to run the program. Can we discover that knowledge automatically?
More specifically:

\vspace{1cm}

\begin{itemize}
\item How do we encode distinctive program features?
\item Can we discern which features are relevant to some error or solution?
\end{itemize}

\vspace{1cm}

We address these questions by using abstract-syntax-tree (AST) patterns to encode program features, and machine-learned rules to discover common errors and solution strategies for beginner Python programs.
