Stop Teaching Code, Solicit Predictions Instead
This is an active area of CS research into what is called “tracing” - looking at a program and reasoning what it’s output would be. In a research study I was involved in 2 years ago, the efficacy of various teaching methods for introductory computer science were measured by student’s ability to trace program execution rather than by the ability to write code.