How young is too young for Python?
The first and unforgiving barrier of entry to learning Python (or any language) is setting up a programming environment. When I look back at my first years, I almost don't recognize what we, as computer science teachers, had to go through. There may be nothing worse than trying to set up compilers and interpreters on school desktops. These applications rarely played nicely with the restrictions that schools place on student accounts. My worst experience involved trying to install Python with the Pygame library. Seemed like a great idea, right? I mean teaching kids Python through making games with Pygame - what's better than that? Well, I spent the summer re-working my curriculum to include Pygame. Then when school finally started, I soon learned that students couldn't run Pygame. Literally impossible. And, I had tested it out on a school computer and everything worked just fine. Unfortunately, that was because I was using a teacher account. It was the students who couldn't use it! My school, like many, restricts student access to computers. I won't go into all the details, but suffice it to say, there was no way that we could get it working with the student accounts, and I just had to teach something else--and scrap months of curriculum.
Nowadays, thanks to cloud based software, it's a whole different story. Students can run Python and even Pygame directly in their browser at repl.it and many other places. This is just one example of the many logistical barriers that used to limit educational options. Cloud software, whether it's repl.it, penjee.com or Firia's Codespace, has removed the challenges of installing a Python programming environment.
Now that we have tackled the tangible logistics, we must address a more cerebral question: What sort of mental skills / abstract thinking abilities are required to learn Python? And at what age do kids typically develop these prerequisite intellectual traits? Before we answer that, let's get a frame of reference from the College Board. The College Board's APCSA curriculum is modeled off of a semester of college computer science, so obviously this is a much higher standard than what we are after, but we can use the College Board's recommendations as a starting point and work backwards to think about when a kid could first learn Python. The College Board states that the prerequisite math class is Algebra I (https://apcentral.collegeboard.org/courses/ap-computer-science-a/course/frequently-asked-questions). Based on the standard math sequencing, Algebra I is a 9th grade class.
So, to be able to handle the intellectual rigors of APCSA, the College Board contends that students should have mastered 9th grade math. As a side note, I personally from experience, would argue that 11th grade is the sweet spot for this APCSA but I have had some 10th graders take the APCSA class and even score a 5 on the exam, the highest score-- illustrating that what we are discussing is just guidelines and that there will always be outliers.
So, when can a kid begin learning Python? Obviously, at a younger age than the college level APCSA class. Let's first delineate some minimum technical aspects of Python that a kid should learn to justify "learning" the language. I mean, after all you can probably teach a 4th grader a line of Python like: print("Hello world"), but that hardly constitutes “learning Python.”
I think it's fair to say that learning Python should include understanding:
In the end, this is an exciting time to be teaching kids to code, whether it's Python or any other language. Typically, middle school coding is limited to block based programming. However, as the barriers of entry continue to decrease and the supportive and supportive learning environments increase, students can start realistically coding in text based languages at an earlier age than ever.