# How do I approach teaching Python to 12-year-olds as a first-time teacher?

I'm currently teaching Python, to three 12-year-olds. They have no experience at all, and my task is to introduce them to programming concepts, and to Python. I'm fairly experienced in programming, and I'll be starting my third year of computer science at university next year.

What I'm trying to ask here is, how do I get my mindset to their level? They struggle with understanding what a variable is, have trouble understanding flow of the program. What can I demonstrate to make them understand better?

I've already tried introducing variables, print function, and some flow controlling through conditionals (all came together in a little calculator), but I seem to fail at making it easy for them to understand.

• BTW, it's not unusual; starting out is rough for virtually everybody. I think you'll find that you've arrived at a good place to get help, though. (Plus, we're glad to have you.) Welcome to Computer Science Educators! – Ben I. Jul 5 '17 at 11:18
• I am a newly qualified teacher, today I tought 3 classes yr7 (11-12years old), and yr8(23-13 years old). We did a code combat hour of code. There are a few bugs, the the first 5 minutes getting started was a pain. One of the buttons on the web page needs clicking 5 to 10 times. But with clear instruction, and help they did it. After that it was a good lesson. Almost all made good progress. One in each class, was refusing to enguage (zero resilience, and one hiccup and they gave up). Everyone else did it (some with help). – ctrl-alt-delor Jul 5 '17 at 16:51
• Hi. Good luck. 12 year olds are just at the early stages of being able to abstract concepts to the level required for programming (at all), so some will struggle seriously while others will take to it like a duck to water. Take it in small steps, choose problems that they can relate to (my 8 yo son is doing Minecraft mods in Java). One day you'll be thinking you're wasting time and resources and they aren't learning anything, then you'll overhear them having an intelligent conversation about programming with someone else – pojo-guy Sep 30 '18 at 23:55

Check out the Python books written by Al Sweigart. His homepage Invent with Python includes some great, free resources that are geared to the age range of your students. In particular he focuses on creating games which is, in my experience, an effective hook. Two books to use to inform your teaching are the following (in order):

I've spent time teaching the age range in question, and most students just starting out aren't really fascinated by the finer details of variables, loops, and conditionals. They want to see something happen, to make the computer do something fun. Games are the perfect vehicle for this to take place.

Part of what makes Al's approach inviting is that there is a lot of supplied code that students can then customize. They might not get why variables matter at first, but if it becomes a discussion about tracking the level of a game or the current high score (or a list of all-time high scores), then the students' interest will be piqued.

I agree with Peter. It needs to be fun, and games really help. It doesn't take much to exercise basic programming concepts such as variables, loops, selection, input, and output. I would start with simple games like Tic-Tac-Toe and Number Guessing Game. Implementing a simple AI would be fun. I've found that in-class programming contests work well too. For example, I've asked students to race to finish a fairly simple program. Another fun project is to use TkInter to allow students to play with graphics. Visual assignments tend to be more fun than stdout.

• I have a test question which asks students to flowchart a number guessing game. – user737 Jul 5 '17 at 15:09
• I eventually went with creating a little text adventure to start with, with each kid creating their own. Thanks for the idea! – kosciCZ Jul 6 '17 at 9:04
• @kosciCZ, you're bringing me back to my days of Zork! :-) – Edwin Torres D.Eng. Jul 6 '17 at 13:11

Full disclosure: I'm one of the founders of CodeHS.

We have a python course on CodeHS that you can try. The curriculum is free to use, and you can sign up as a teacher account to be able to see your students' code and test out their programs.

You can see more about the course here: https://codehs.com/info/curriculum/intropython

It's designed for high schoolers, but the first unit teaches Tracy the Turtle, which is a turtle graphics implementation in python in the browser that's really visual and accessible for younger students.

You learn to teach the turtle to move around the canvas and draw different shapes like this:

• Gosh, I used to make shapes on the terminal with asterisks. Halcyon days. – user737 Jul 5 '17 at 15:08
• @ZachGalant, you may want to check out this question: cseducators.stackexchange.com/questions/3441/… – Ben I. Aug 31 '17 at 20:30

I am 12 and I can tell you what I did to learn Python. How I learned about Python was when I saw a video about a guy getting a wpm of 162 on a type-race-game, so I for some reason decided that I wanted to make a type-race-game. I knew about coding at the time, because my dad taught me HTML, when I was 9, but I did not like it, so I moved on.

When I was trying to learn how to code, I remembered the site codeacademy.com from when I was 9. I went to the website and there were many coding tutorials, for many different languages. I was looking through them and I saw Python. I remembered Python because my uncle (who works in IT) told me about it during the summer, so I decided to look at it. I looked at it for a while, but because of my ADHD, I couldn't sit there for long, so I kept hopping from site to site, mainly YouTube, to learn about Python. I used a site called repl.it as my IDE to code in Python.

After about 1 month, I figured out the basics like print and if. I could make a simple program, that when you say "hi" it says "hi" back. That is about it. 4 months of this went by of hopping from site to site learning about Python. It was finally Christmas that I got all the parts to build a computer, because my laptop was very slow and filled with viruses. It took almost 5 seconds just to load a site.

With my new computer it was faster to do stuff, and made learning way easier. Another 4 months went by and I was finally done. If you want to see it, here's the link https://repl.it/@Luke0/Writing-Game-1.

So my answer to that question is dedication, or just keep coming back to it, like I did. That is why it took me almost a year to learn.

• Hi bahbooshka, welcome to Computer Science Educators. We always welcome student insights here! – Ben I. Sep 29 '18 at 12:43
• Hi. I hope my edits make your post a bit more readable. Welcome to the site. – Buffy Sep 30 '18 at 13:09
• I like your contribution, it is good to see the perspective of a learner. Thanks. You can improve your writing by reducing the length of your sentences. Try using subject-verb-object, for most sentences. e.g. “The dog chased the orange ball.”. – ctrl-alt-delor Sep 30 '18 at 14:24
• Here is my attempt to edit you first paragraph. It is a lot shorter now. It contains subject-verb-object, but also some extensions (using a comma). “I am 12 years old. I learned about Python, when I saw a video about a guy getting a wpm of 162 , on a type-race-game. I decided that, I wanted to make a type-race-game. I knew about coding, because my dad taught me HTML, when I was 9, but I did not like it, at this time.” Hope this feedback is useful. Keep learning. – ctrl-alt-delor Sep 30 '18 at 14:26

I've been in a similar situation. Like the other responders, I find that visual and game-related applications, often using high-level ideas like objects and methods/functions, will get and keep attention better than learning the "traditional" way from basic concepts like variables, operators, and control flow.

If your students like Minecraft (and haven't sold their soul's completely to Fortnite yet), you might look into some of the many activities online for modding Minecraft with Python.

Here's some examples: https://education.minecraft.net/lessons/teach-python-with-minecraft-pi/

https://projects.raspberrypi.org/en/projects/getting-started-with-minecraft-pi/5

https://nostarch.com/programwithminecraft

I see you've already accepted a great answer, but I'd like to give my knee-jerk reactions to your questions directly.

What I'm trying to ask here is, how do I get my mindset to their level?

In this question here we were talking about how to teach binary to 6-8 year-olds. What I said there I think touches on this question (I said a lot and am not going to repeat it here).

Very generally, what I do is assume nothing as far as previous knowledge and I especially try to keep things very goal/task focused, meaning, discussing what we want the computer to do, and the higher level ideas of how the computer does it. I only break things down into something more technical and specific when needed.

Language is especially important! Only introduce one term at a time and explain them thoroughly each time you add a new word to the jargon you want someone to understand. It actually helps to know, and use often, other (preferably simpler) terms while explaining an idea. For example, a variable is a "labeled box", or a "small dry erase board". A function is a "list of instructions". This actually brings me to your next question:

They struggle with understanding what a variable is, have trouble understanding flow of the program. What can I demonstrate to make them understand better?

Use as many real-world objects and analogies as possible. As I said above, variables are labeled boxes, cubbies, white boards, or any other object that holds information and can be emptied and refilled. Functions are just lists, and things like if statements can be thought of as "splits in a road" of instructions (or steps) your program is following.

I found it really useful when couching in college to use office workers (or any person doing any job) to represent objects and behaviors within a program. Personifying parts of a program can really help a lot in explaining how they work together.

... if it becomes a discussion about tracking the level of a game or the current high score ... -- Peter

It needs to be fun, and games really help. -- Edwin

Like the other responders, I find that visual and game-related applications ... will get and keep attention better than learning the "traditional" way ... -- Matthew

I really like all the talk of having kids make games in order to learn programming. When I was 14 and first learning C++ I made lots of little games too. I'd like to caution not to lose focus though. Regardless of what kind of program is being made that doesn't change how the teaching itself, the careful explanation of ideas, needs to be done. Please, make the packaging colorful and interesting, but keep in mind that concepts build on each other and need to be addressed in an order that makes sense and keeps questions flowing naturally.

• You've been posting some high-quality answers lately. Welcome to our community! Feel free to drop by the chat and say hi. It's lately become more of a message board than a chat room, but that could always change, and that's where the most active users hang out :) – Ben I. Nov 9 '18 at 21:45
• Thank you. :-) I'll definitely check it out as soon as I get a chance. – RoboticForest Nov 17 '18 at 21:43

I have used 3 techniques.

• Bottom up: teaching the parts and having them slowly able to create bigger programs. (This was the least good. It was not interesting, they did not learn as much. However it could be mixed with the others.)
• Top down: I remind pupils that in Literature class they read poems and novels that they could not yet write. I then provide a working program, and get them to read it, and make guesses as to what bits do, and to change them. ”What happens if I change that?”
• CodeHS (see @ZachGalant's answer. I first tried this after reading the answer). Pupils liked these lessons, and I got some good feedback on progress. However it stopped working (at school) in week 2. (Then it was the end of term.)
• Avoid variables as long as possible: introduce parameterisation before mutation (a long way before), mutation should be one of the last things taught.

I also want to try ideas based on Bret Victor's ideas of direct manipulation, and immediate feedback: no compilation, no pressing run. Just change the code, and see the change.

I taught kids Python last year, and I used "Python for Kids: A Playful Introduction To Programming" as a textbook.

But... Before I taught them Python, I taught them Scratch for several months so that they can grasp the basic concept of Scratch.

Then, I taught them how to type fast because I noticed that their typing skills are not up to be ready for coding. There are lots of fun typing game websites. Their favorite was nitrotype.com.

When I taught Python, I basically walked through the Python for Kids textbook, and made sure that they finished all the questions in the textbook. Kids really enjoyed the last project, Snake game, in the book.

My lecture notes on Python can be found here -- https://github.com/geekdojo-io

The important thing to focus on is basic programming concepts. The language itself isn't as important at this early stage. I'll shamelessly promote my book, because it is appropriate here: The Super Simple Programming Book: Learn Basic Programming Concepts With Python.

It's a quick read, and it uses short and simple programs to teach the fundamental programming concepts like data, input/output, loops, decisions, etc. The book assumes no prior programming experience or knowledge. It uses a friendly and inviting tone as well. I must warn you that it isn't a good reference, because it doesn't aim to be. The goal is to quickly build a foundation, so students can continue their programming journeys on their own.

Maybe do you want to try this:

Variables

1. Organize plays around it, for example: to identify variables vs constants
2. Organize puzzle to organize a complete function
3. Divide your kids into small groups, and then give them a task, for example how to build a PC

Remember little kids understand playing over writing code

You can use platforms such as code.org software like scratch, why?

1. Kids need first at all understand, what is logic, whats is programming languages
2. If kids see this as an advendure they will be more agree to participate and practice

If you prefer you can use interactive videos to explain how code works, I mean:

Kids need to know

1. How a computer proceses and work with variables and constants
2. Maybe do you wanna demosntrate final products with that language to explain kids this "programming language is like lego pieces but in inspite if take with your hands pieces you write them"