Analyzing Cognitive Effort in Python Programming: Eye-Tracking Insights on for Loops and Nested Loop Complexity
摘要
This study explores the comprehension of Python programming constructs, specifically for loops and nested loops, through the analysis of eye-tracking data. Python is a widely used language in programming education, and understanding how both novice and experienced programmers interact with these constructs is essential for improving teaching methods and user interfaces. The research focuses on cognitive load and difficulty areas associated with for loops, utilizing the Gazepoint GP3 HD eye-tracking device to capture various eye movement metrics such as pupil dilation and blink rates. Participants, including both programmers and non-programmers, were shown Python code snippets featuring simple and nested for loops, with randomized displays to control for learning effects. The study employed a repeated-measures design, where each participant analyzed the same set of code and chose the correct output from multiple options. Eye-tracking data was used to assess cognitive strain by measuring changes in pupil dilation and blink frequency during the code analysis. Results revealed that nested loops induced higher cognitive load than simple loops, as evidenced by greater pupil dilation and more frequent blinking. Novice programmers demonstrated higher cognitive strain than experienced ones, although both groups struggled with nested loops. Accuracy in identifying the correct loop output also declined with increased complexity, with nested loops proving the most challenging. These findings highlight the potential of eye-tracking to optimize programming education by identifying areas that cause cognitive overload, offering valuable insights for both educators and developers to improve learning environments and tools.