How young is too young for Python? Guest post by Vernon Morris

Thanks to Vernon Morris for contributing this blog post. Vernon has been teaching for over 15 years as both an NYC Teaching fellow and a computer science teacher at the Harrison central school district in Harrison, NY. He has taught Python and AP Computer Science A, and he has been an AP A reader.


How young is too young for Python?

The answer to that question has changed a lot over the last decade or so. I've been teaching kids computer programming for the last 15 years, and it's amazing to think about the radical changes to this field over that span; whether you're talking about teaching Java, Javascript, or Python, there are so many new and engaging ways to learn these days.  Python, of all the languages, has long been a popular introductory language. But how young is too young for learning 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: 

1) variables  
2) functions 
3) control structures  
4) loops

I have spent several years working with middle schoolers. While there is no one right answer to this question, the supportive learning environments of websites like Firia's Codespace and Penjee.com make learning Python much easier for young kids. Personally, I have been able to introduce Python to kids in 7th grade with pretty consistent success. And by this, I mean I was able to teach all 4 of the components above including looping.  Students were able to write programs, on their own, and incorporate all of the above components including looping . Part of the reason that middle schoolers can master such advanced concepts, I believe, is attributable to the engaging learning environments that this newer generation of websites have created. Kids love to light up the micro:bit’s lights and Firia's JumpStart Python curriculum is very supportive for first time learners. Kids love to move Penjee's penguin around via Python code.  These types of experiences hook kids and drive them to want to overcome the challenges of some of the more complex parts of the language .

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.