Cognitive diagnosis plays an important role in intelligent educational scenarios as a method that can reveal students' knowledge mastery. Existing cognitive diagnostic methods are mainly applicable to objective questions in core subject areas (e.g., mathematics); however, in the field of programming, where the questions are subjective, no research has been conducted to apply cognitive diagnostics to analyze and assess the impact of students' subjective answers on students' knowledge acquisition. Therefore, we explored how to design a cognitive diagnostic approach that can be applied in the programming domain. In this paper, we design a neural network-based cognitive diagnostic model, PECDM, where our approach not only exploits the interactions between the student factor and the exercise factor, but also includes the student answer source code and the difficulty of the exercise among the diagnostic factors, further considering that the student's knowledge mastery can be captured from the student's subjective answers (source code), and finally uses multiple fully connected layers to interactions are modeled, resulting in more accurate and interpretable diagnostics. We conduct relevant experiments on the codeforces dataset, and the experimental results show that the accuracy of our designed PECDM model is about 95%, which is better in terms of accuracy, rationality, and interpretability when compared with other cognitive diagnostic models.